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

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

No files matched your search

+15 -6
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"
}