try to get version from runtime/debug

This commit is contained in:
Sebastian Mark 2024-11-09 14:56:44 +01:00
parent 8f0b197c3e
commit 95842b00fd
2 changed files with 15 additions and 9 deletions

View file

@ -1,16 +1,23 @@
package metadata package metadata
import ( import (
"os" "fmt"
"runtime/debug"
"strings" "strings"
) )
func getVersion() string { var (
content, _ := os.ReadFile("version.txt") GoTomatoVersion = "" // The GoTomato version
version := strings.TrimSpace(string(content)) ProtocolVersion = "" // The protocol version
)
return version func init() {
info, ok := debug.ReadBuildInfo()
fmt.Printf("%v", info)
if !ok {
GoTomatoVersion = "unknown"
} }
var GoTomatoVersion = getVersion() // The GoTomato version GoTomatoVersion = info.Main.Version
var ProtocolVersion = strings.Split(GoTomatoVersion, ".")[0] // The protocol version ProtocolVersion = strings.Split(GoTomatoVersion, ".")[0]
}

View file

@ -1 +0,0 @@
devel