From cdfdcd24a217ed19f406b00ec4398461f9d029c1 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 5 Jun 2019 02:52:35 -0700 Subject: [PATCH] fix version number handling Signed-off-by: Jeff Carr --- config.go | 17 ++++++++++++++++- gui-debug.go | 5 +++++ gui-splash.go | 6 +++--- main.go | 9 ++++++++- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/config.go b/config.go index 21411ad..ab45475 100644 --- a/config.go +++ b/config.go @@ -238,7 +238,10 @@ func parseConfig() { _, currentRef, _ := shell.Run("git rev-list -1 HEAD") log.Println("CURRENT VERSION git ref =", currentRef) - config.Gitref = currentRef + config.Gitref = strings.TrimSuffix(currentRef, "\n") + + _, goversion, _ := shell.Run("go version") + config.Goversion = strings.TrimSuffix(goversion, "\n") config.Dirty = false if (ref != currentRef) { @@ -246,6 +249,18 @@ func parseConfig() { } } +// TODO: fix this to chomp \n \r NULL \t and ' ' +func chomp(s string) string { +// var bytesBuffer bytes.Buffer +// var bytesSplice []byte +// byteSlice := bytesBuffer.Bytes() +// b := bytes.Trim(byteSlice, "\x00") // removes NULL + + cmd := strings.TrimSpace(s) // this is like 'chomp' in perl + cmd = strings.TrimSuffix(cmd, "\n") // this is like 'chomp' in perl + return cmd +} + func perl(a ...interface{}) { log.Println("reflect.TypeOf(a) =", reflect.TypeOf(a)) } diff --git a/gui-debug.go b/gui-debug.go index 4c64a50..2d002df 100644 --- a/gui-debug.go +++ b/gui-debug.go @@ -44,6 +44,10 @@ func debugClick(b *gui.GuiButton) { makeButton(Xbox1, nil, nil, "Debug IPv6", "SUBDOMAIN", func (*gui.GuiButton) { log.Println("Need to add IPv6 debugging here") }) + Ybox3 := gui.NewBox(Ybox1, gui.Yaxis, "subdomain Y1 test") + gui.NewLabel(Ybox3, "git rev-list: " + config.Gitref) + gui.NewLabel(Ybox3, "go build version: " + config.Goversion) + gui.NewLabel(Ybox3, "build date: " + BUILDTIME) Ybox2 := gui.NewBox(hardXbox, gui.Yaxis, "subdomain Y test") makeButton(Ybox2, nil, nil, "Hide all tabs", "SUBDOMAIN", func (*gui.GuiButton) { @@ -107,6 +111,7 @@ func runTestExecClick(b *gui.GuiButton) { func runSimpleCommand(s string) { cmd := strings.TrimSpace(s) // this is like 'chomp' in perl + cmd = strings.TrimSuffix(cmd, "\n") // this is like 'chomp' in perl cmdArgs := strings.Fields(cmd) runCommand(cmdArgs) } diff --git a/gui-splash.go b/gui-splash.go index 9ca4be8..d56922a 100644 --- a/gui-splash.go +++ b/gui-splash.go @@ -24,11 +24,11 @@ func showSplashBox(gw *gui.GuiWindow) *gui.GuiBox { gui.NewLabel(box,"OS: " + runtime.GOOS) } - gui.NewLabel(box, "Version: " + VERSION) + gui.NewLabel(box, "Version: " + config.Version) if (config.Debug) { - gui.NewLabel(box, "git rev-list: " + GITCOMMIT) - gui.NewLabel(box, "go build version: " + GOVERSION) + gui.NewLabel(box, "git rev-list: " + config.Gitref) + gui.NewLabel(box, "go build version: " + config.Goversion) gui.NewLabel(box, "build date: " + BUILDTIME) } diff --git a/main.go b/main.go index 54e02cf..1ef12d7 100644 --- a/main.go +++ b/main.go @@ -98,6 +98,12 @@ func main() { // golang application IMHO parseConfig() + if (config.Dirty) { + config.Version = VERSION + " (dirty)" + } else { + config.Version = VERSION + } + for key, foo := range config.Accounts { log.Println("FOUND ACCOUNT = ", key, foo) } @@ -107,7 +113,8 @@ func main() { v185AAAA := lookupAAAA("v000185.testing.com.customers.wprod.wit.com") log.Println("v185AAA = ", v185AAAA) - go gorillaDial("ccp.wit.com:9000") + // go gorillaDial("ccp.wit.com:9000") + go gorillaDial("stackapi-ccp.stackapi.customers.wit.com:9000") go gui.WatchGUI() // use this to discover what the OS thinks it's hostname is