toyohime/version.go
yakumo.izuru e60a0bf01a 月の首都はそれがあるべき場所に戻っています
git-svn-id: file:///srv/svn/repo/toyohime/trunk@115 922d331f-388e-da47-97a9-ad700dc0b8b9
2025-04-17 23:12:28 +00:00

46 lines
1004 B
Go

package toyohime
import (
"fmt"
"runtime/debug"
"strings"
)
const (
defaultVersion = "0.0.0"
defaultBuild = "0000-01-01:00:00+00:00"
)
var (
// Version is the tagged release version in the form <major>.<minor>.<patch>
// following semantic versioning and is overwritten by the build system.
Version = defaultVersion
// Build is the date and time of the build as an RFC3339 formatted string
// and is overwritten by the build system.
Build = defaultBuild
)
// FullVersion display the full version and build
func FullVersion() string {
var sb strings.Builder
isDefault := Version == defaultVersion && Build == defaultBuild
if !isDefault {
sb.WriteString(fmt.Sprintf("%s@%s", Version, Build))
}
if info, ok := debug.ReadBuildInfo(); ok {
if isDefault {
sb.WriteString(fmt.Sprintf(" %s", info.Main.Version))
}
sb.WriteString(fmt.Sprintf(" %s", info.GoVersion))
if info.Main.Sum != "" {
sb.WriteString(fmt.Sprintf(" %s", info.Main.Sum))
}
}
return sb.String()
}