1
0
mirror of https://github.com/cmur2/miflorad.git synced 2025-06-26 12:30:23 +02:00

module: bump minimum Go version to 1.18 and use debug.ReadBuildInfo()

This commit is contained in:
cn
2022-03-18 00:21:53 +01:00
parent 0268126d70
commit 72c4c94cb7
4 changed files with 20 additions and 11 deletions

View File

@ -1,12 +1,21 @@
package main
// program version, will be populated on build
var version string
import (
"runtime/debug"
)
func getVersion() string {
if version == "" {
return "dev"
} else {
return version
info, ok := debug.ReadBuildInfo()
if !ok {
return "unknown"
}
for _, kv := range info.Settings {
switch kv.Key {
case "vcs.revision":
return kv.Value[0:8]
}
}
return "unknown"
}