1// Package moxvar provides the version number of a mox build.
2package moxvar
3
4import (
5 "runtime/debug"
6)
7
8// Version is set at runtime based on the Go module used to build.
9var Version = "(devel)"
10
11func init() {
12 buildInfo, ok := debug.ReadBuildInfo()
13 if !ok {
14 return
15 }
16 Version = buildInfo.Main.Version
17 if Version == "(devel)" {
18 var vcsRev, vcsMod string
19 for _, setting := range buildInfo.Settings {
20 if setting.Key == "vcs.revision" {
21 vcsRev = setting.Value
22 } else if setting.Key == "vcs.modified" {
23 vcsMod = setting.Value
24 }
25 }
26 if vcsRev == "" {
27 return
28 }
29 Version = vcsRev
30 switch vcsMod {
31 case "false":
32 case "true":
33 Version += "+modifications"
34 default:
35 Version += "+unknown"
36 }
37 }
38}
39