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"
|
|
|
|
)
|
|
|
|
|
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)
|
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 {
|
|
|
|
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)
|
|
|
|
}
|