mirror of
https://git.mills.io/saltyim/saltyim.git
synced 2024-06-27 01:08:20 +00:00
38 lines
920 B
Go
38 lines
920 B
Go
package saltyim
|
|
|
|
import (
|
|
"fmt"
|
|
"runtime/debug"
|
|
"strings"
|
|
)
|
|
|
|
var (
|
|
// Version is the tagged release version in the form <major>.<minor>.<patch>
|
|
// following semantic versioning and is overwritten by the build system.
|
|
Version = "0.0.0"
|
|
|
|
// Commit is the commit sha of the build (normally from Git) and is overwritten
|
|
// by the build system.
|
|
Commit = "HEAD"
|
|
|
|
// Build is the date and time of the build as an RFC3339 formatted string
|
|
// and is overwritten by the build system.
|
|
Build = "0000-01-01:00:00+00:00"
|
|
)
|
|
|
|
// FullVersion display the full version and build
|
|
func FullVersion() string {
|
|
var sb strings.Builder
|
|
|
|
sb.WriteString(fmt.Sprintf("%s@%s %s", Version, Commit, Build))
|
|
|
|
if info, ok := debug.ReadBuildInfo(); ok {
|
|
sb.WriteString(fmt.Sprintf(" %s %s", info.Main.Version, info.GoVersion))
|
|
if info.Main.Sum != "" {
|
|
sb.WriteString(fmt.Sprintf(" %s", info.Main.Sum))
|
|
}
|
|
}
|
|
|
|
return sb.String()
|
|
}
|