summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-02-29 17:27:50 -0600
committerJeff Carr <[email protected]>2024-02-29 17:27:50 -0600
commita6351e586d3ac7fe4a66c804a87f82ed1a9b961b (patch)
treea93959e3312a0e200a1cac254d4ad96dd894d958
parent3e2805017e0f21b462eca2002690b68744127800 (diff)
process/get GUI versionv0.22.0v0.21.1
-rw-r--r--main.go50
1 files changed, 48 insertions, 2 deletions
diff --git a/main.go b/main.go
index fe6ebc6..e4944e7 100644
--- a/main.go
+++ b/main.go
@@ -1,8 +1,10 @@
package gui
import (
+ "errors"
"fmt"
"os"
+ "runtime/debug"
"go.wit.com/log"
"go.wit.com/widget"
@@ -32,8 +34,12 @@ func init() {
me.guiChan = make(chan widget.Action, 1)
- fmt.Println("GO GUI version <ldflags here>", showVersion() + "<Bromeliaceae>")
- log.Sleep(1)
+ version, err := getGuiVersion()
+ fmt.Println("GO GUI version", version, showVersion()+"<Bromeliaceae>", err)
+ if version == "" {
+ log.Warn("Warning: compiled without version", err)
+ log.Sleep(1)
+ }
go watchCallback()
}
@@ -57,6 +63,46 @@ func showVersion() string {
return color1 + " " + color2 + " " + color3 + " " + color4 + " " + color5 + " " + color6 + " " + color7 + " " + color8
}
+var GUIVERSION string
+
+func getGuiVersion() (string, error) {
+ var found string
+ tmp, ok := debug.ReadBuildInfo()
+ if !ok {
+ return "", errors.New("debug.ReadBuildInfo() not ok")
+ }
+ if tmp == nil {
+ return "", errors.New("compiled without go module support")
+ }
+ fmt.Println("mod.Path = ", tmp.Path)
+ fmt.Println("mod.Main.Path = ", tmp.Main.Path)
+ fmt.Println("mod.Main.Version = ", tmp.Main.Version)
+ fmt.Println("mod.Main.Sum = ", tmp.Main.Sum)
+ for _, value := range tmp.Deps {
+ if value.Path == "go.wit.com/gui" {
+ found = value.Version
+ }
+ fmt.Println("\tmod.Path = ", value.Path)
+ fmt.Println("\tmod.Version = ", value.Version)
+ }
+ if found != "" {
+ log.Println("GUI build version:", found)
+ return found, nil
+ }
+ if GUIVERSION != "" {
+ log.Println("GUI build ldflag:", GUIVERSION)
+ return GUIVERSION, nil
+ }
+ if os.Getenv("GUIVERSION") != "" {
+ found = os.Getenv("GUIVERSION") + "-dirty"
+ log.Println("GUI build $GUIVERSION", found)
+ return found, nil
+ }
+ found = "pre-v1-GO111"
+ log.Println("GUI build version:", found)
+ return found, errors.New("GO111 developer build")
+}
+
// lookup the widget by the id sent from the toolkit
func (n *Node) findId(i int) *Node {
if n == nil {