2018-08-15 16:34:50 +02:00
|
|
|
package meta
|
|
|
|
|
2018-08-30 20:41:50 +02:00
|
|
|
import (
|
2020-10-05 20:05:00 +02:00
|
|
|
"fmt"
|
2018-08-30 20:41:50 +02:00
|
|
|
"strconv"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2023-03-09 18:41:41 +01:00
|
|
|
var (
|
|
|
|
name = "prism-bin"
|
|
|
|
version = "unknown"
|
|
|
|
commit = "unknown"
|
|
|
|
commitLong = "unknown"
|
|
|
|
branch = "unknown"
|
|
|
|
Time = "unknown"
|
|
|
|
BuildTime time.Time
|
|
|
|
)
|
|
|
|
|
|
|
|
// Name returns main application name
|
|
|
|
func Name() string {
|
|
|
|
return name
|
|
|
|
}
|
|
|
|
|
|
|
|
// Version returns current application version
|
|
|
|
func Version() string {
|
|
|
|
return version
|
|
|
|
}
|
|
|
|
|
|
|
|
// FullName returns current app version, commit and build time
|
|
|
|
func FullName() string {
|
|
|
|
return fmt.Sprintf(
|
|
|
|
`Name: %v
|
|
|
|
Version: %v
|
|
|
|
branch: %v
|
|
|
|
commit: %v
|
|
|
|
commit long: %v
|
|
|
|
build date: %v`, Name(), Version(), branch, commit, commitLong, BuildTime.String())
|
|
|
|
}
|
2018-08-30 20:41:50 +02:00
|
|
|
|
|
|
|
func init() {
|
|
|
|
if Time != "" {
|
|
|
|
t, err := strconv.Atoi(Time)
|
2020-10-05 20:05:00 +02:00
|
|
|
if err == nil {
|
|
|
|
BuildTime = time.Unix(int64(t), 0).UTC()
|
2018-08-30 20:41:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-05 20:05:00 +02:00
|
|
|
|
|
|
|
func VersionString() string {
|
|
|
|
var buildTime string
|
|
|
|
if BuildTime.IsZero() {
|
|
|
|
buildTime = "<now>"
|
|
|
|
} else {
|
|
|
|
buildTime = BuildTime.Format(time.RFC3339)
|
|
|
|
}
|
|
|
|
|
|
|
|
return fmt.Sprintf("version %s, built %s", version, buildTime)
|
|
|
|
}
|