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
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

View file

@ -1 +0,0 @@
devel