mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 17:04:39 +03:00
mox!
This commit is contained in:
38
moxvar/version.go
Normal file
38
moxvar/version.go
Normal file
@ -0,0 +1,38 @@
|
||||
// Package moxvar provides the version number of a mox build.
|
||||
package moxvar
|
||||
|
||||
import (
|
||||
"runtime/debug"
|
||||
)
|
||||
|
||||
// Version is set at runtime based on the Go module used to build.
|
||||
var Version = "(devel)"
|
||||
|
||||
func init() {
|
||||
buildInfo, ok := debug.ReadBuildInfo()
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
Version = buildInfo.Main.Version
|
||||
if Version == "(devel)" {
|
||||
var vcsRev, vcsMod string
|
||||
for _, setting := range buildInfo.Settings {
|
||||
if setting.Key == "vcs.revision" {
|
||||
vcsRev = setting.Value
|
||||
} else if setting.Key == "vcs.modified" {
|
||||
vcsMod = setting.Value
|
||||
}
|
||||
}
|
||||
if vcsRev == "" {
|
||||
return
|
||||
}
|
||||
Version = vcsRev
|
||||
switch vcsMod {
|
||||
case "false":
|
||||
case "true":
|
||||
Version += "+modifications"
|
||||
default:
|
||||
Version += "+unknown"
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user