You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
regolancer/version.go

29 lines
616 B
Go

package main
import (
"fmt"
"os"
"runtime/debug"
)
func printVersion() {
info, ok := debug.ReadBuildInfo()
if !ok {
fmt.Printf("No build info available")
} else {
settings := map[string]string{}
for _, bs := range info.Settings {
settings[bs.Key] = bs.Value
}
version := info.Main.Version
if rev, ok := settings["vcs.revision"]; ok && version == "(devel)" {
version = "git" + rev[:8]
}
if settings["vcs.modified"] == "true" {
version += "-dirty"
}
fmt.Printf("Regolancer %s, built with %s\nSource: https://github.com/rkfg/regolancer\n", version, info.GoVersion)
}
os.Exit(1)
}