reflector.go/meta/meta.go

37 lines
532 B
Go
Raw Normal View History

2018-08-15 16:34:50 +02:00
package meta
2018-08-30 20:41:50 +02:00
import (
"fmt"
2018-08-30 20:41:50 +02:00
"strconv"
"time"
)
2018-08-15 16:34:50 +02:00
var Version = ""
2018-08-30 20:41:50 +02:00
var Time = ""
var BuildTime time.Time
func init() {
if Time != "" {
t, err := strconv.Atoi(Time)
if err == nil {
BuildTime = time.Unix(int64(t), 0).UTC()
2018-08-30 20:41:50 +02:00
}
}
}
func VersionString() string {
version := Version
if version == "" {
version = "<unset>"
}
var buildTime string
if BuildTime.IsZero() {
buildTime = "<now>"
} else {
buildTime = BuildTime.Format(time.RFC3339)
}
return fmt.Sprintf("version %s, built %s", version, buildTime)
}