From 95842b00fdda5878b6ad17b2c31e294c4b9145a5 Mon Sep 17 00:00:00 2001 From: Sebastian Mark Date: Sat, 9 Nov 2024 14:56:44 +0100 Subject: [PATCH] try to get version from runtime/debug --- internal/metadata/version.go | 23 +++++++++++++++-------- version.txt | 1 - 2 files changed, 15 insertions(+), 9 deletions(-) delete mode 100644 version.txt diff --git a/internal/metadata/version.go b/internal/metadata/version.go index 13b8f6e..6a9529b 100644 --- a/internal/metadata/version.go +++ b/internal/metadata/version.go @@ -1,16 +1,23 @@ package metadata import ( - "os" + "fmt" + "runtime/debug" "strings" ) -func getVersion() string { - content, _ := os.ReadFile("version.txt") - version := strings.TrimSpace(string(content)) +var ( + GoTomatoVersion = "" // The GoTomato version + ProtocolVersion = "" // The protocol version +) - return version +func init() { + info, ok := debug.ReadBuildInfo() + fmt.Printf("%v", info) + if !ok { + GoTomatoVersion = "unknown" + } + + GoTomatoVersion = info.Main.Version + ProtocolVersion = strings.Split(GoTomatoVersion, ".")[0] } - -var GoTomatoVersion = getVersion() // The GoTomato version -var ProtocolVersion = strings.Split(GoTomatoVersion, ".")[0] // The protocol version diff --git a/version.txt b/version.txt deleted file mode 100644 index d64531f..0000000 --- a/version.txt +++ /dev/null @@ -1 +0,0 @@ -devel