From 3a4630d83040c9d657127eee8cf03f24ddb8fe1e Mon Sep 17 00:00:00 2001
From: rokath
Date: Thu, 21 Mar 2024 10:46:01 +0100
Subject: [PATCH] BuildInfo added to self-compiled compiled binary.
---
go.mod | 2 ++
internal/args/handler.go | 8 ++++++++
2 files changed, 10 insertions(+)
diff --git a/go.mod b/go.mod
index 48824c001..e68ac5717 100644
--- a/go.mod
+++ b/go.mod
@@ -5,6 +5,7 @@ go 1.20
require (
github.com/awesome-gocui/gocui v1.1.0
github.com/fsnotify/fsnotify v1.6.0
+ github.com/kr/pretty v0.1.0
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d
github.com/pkg/errors v0.9.1
github.com/rokath/cobs v0.0.0-20230425030040-4ebbe9b903b9
@@ -22,6 +23,7 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gdamore/encoding v1.0.0 // indirect
github.com/gdamore/tcell/v2 v2.6.0 // indirect
+ github.com/kr/text v0.1.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
diff --git a/internal/args/handler.go b/internal/args/handler.go
index 59d442a5a..af38c30ac 100644
--- a/internal/args/handler.go
+++ b/internal/args/handler.go
@@ -10,9 +10,11 @@ import (
"fmt"
"io"
"os"
+ "runtime/debug"
"sync"
"time"
+ "github.com/kr/pretty"
"github.com/rokath/trice/internal/com"
"github.com/rokath/trice/internal/decoder"
"github.com/rokath/trice/internal/do"
@@ -43,6 +45,12 @@ func Handler(w io.Writer, fSys *afero.Afero, args []string) error {
Date = fmt.Sprint(err) // just in case, simply show the error
}
}
+ bi, ok := debug.ReadBuildInfo()
+ if !ok {
+ fmt.Println("buildInfo not ok")
+ } else {
+ pretty.Println(bi)
+ }
}
// Verify that a sub-command has been provided: os.Arg[0] is the main command (trice), os.Arg[1] will be the sub-command.
|