From c3d223088cbadbed6f10e2462401af4f73cc7a55 Mon Sep 17 00:00:00 2001 From: Caleb Woodbine Date: Wed, 31 May 2023 14:39:54 +1200 Subject: [PATCH] feat: add debug info to webthingy show all the build info Signed-off-by: Caleb Woodbine --- cmd/webthingy/main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmd/webthingy/main.go b/cmd/webthingy/main.go index a8e6fb6..fef167c 100644 --- a/cmd/webthingy/main.go +++ b/cmd/webthingy/main.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "net/http" + "runtime/debug" "time" "github.com/BobyMCbobs/sample-ko-monorepo/pkg/common" @@ -44,6 +45,15 @@ func NewWebThingy() *WebThingy { } func (w *WebThingy) Run() { + info, _ := debug.ReadBuildInfo() + var debugInfo string + for _, i := range info.Settings { + switch i.Key { + case "vcs.revision", "vcs.time", "vcs.modified": + debugInfo += i.Key + " " + i.Value + " " + } + } + log.Printf("%v", debugInfo) log.Printf("Listening on HTTP port '%v'\n", w.server.Addr) log.Fatal(w.server.ListenAndServe()) }