6
1
mirror of https://git.mills.io/saltyim/saltyim.git synced 2024-06-16 03:48:24 +00:00
prologic-saltyim/version.go
James Mills 668cae61b7 Fix version info -v/--version (#138)
Co-authored-by: James Mills <prologic@shortcircuit.net.au>
Reviewed-on: https://git.mills.io/saltyim/saltyim/pulls/138
Reviewed-by: xuu <xuu@noreply@mills.io>
2022-04-03 23:13:32 +00:00

30 lines
547 B
Go

package saltyim
import (
"fmt"
"runtime/debug"
)
var (
// Version release version
Version = "0.0.0"
// Commit will be overwritten automatically by the build system
Commit = "HEAD"
)
// FullVersion display the full version and build
func FullVersion() string {
if Version != "0.0.0" && Commit != "HEAD" {
return fmt.Sprintf("%s@%s", Version, Commit)
}
info, ok := debug.ReadBuildInfo()
if !ok {
return "unknown"
}
return fmt.Sprintf(
"%s built with %s (checksum: %s)",
info.Main.Version, info.GoVersion, info.Main.Sum,
)
}