1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00
Tom Limoncelli a07a8cc731 Release v3.4.0
2020-10-12 12:13:07 -04:00

48 lines
1.1 KiB
Go

package version
import (
"fmt"
"runtime/debug"
"strconv"
"time"
)
// Version management. Goals:
// 1. Someone who just does "go get" has at least some information.
// 2. If built with build/build.go, more specific build information gets put in.
// Update the number here manually each release, so at least we have a range for go-get people.
var (
SHA = ""
Version = "3.4.0"
BuildTime = ""
)
var versionCache string
// VersionString returns the version banner.
func VersionString() string {
if versionCache != "" {
return versionCache
}
var version string
if SHA != "" {
version = fmt.Sprintf("%s (%s)", Version, SHA)
} else {
version = fmt.Sprintf("%s-dev", Version) // no SHA. '0.x.y-dev' indicates it is run from source without build script.
}
if info, ok := debug.ReadBuildInfo(); !ok && info == nil {
version += " (non-modules)"
}
if BuildTime != "" {
i, err := strconv.ParseInt(BuildTime, 10, 64)
if err == nil {
tm := time.Unix(i, 0)
version += fmt.Sprintf(" built %s", tm.Format(time.RFC822))
}
}
versionCache = version
return version
}