Always print long version at startup

This commit is contained in:
Jakob Borg 2014-04-19 16:40:19 +02:00
parent f76fe1ac7a
commit 264bcbc78c
1 changed files with 9 additions and 6 deletions

View File

@ -29,14 +29,18 @@ import (
const BlockSize = 128 * 1024 const BlockSize = 128 * 1024
var ( var (
Version = "unknown-dev" Version = "unknown-dev"
BuildStamp = "0" BuildStamp = "0"
BuildDate time.Time BuildDate time.Time
LongVersion string
) )
func init() { func init() {
stamp, _ := strconv.Atoi(BuildStamp) stamp, _ := strconv.Atoi(BuildStamp)
BuildDate = time.Unix(int64(stamp), 0) BuildDate = time.Unix(int64(stamp), 0)
date := BuildDate.UTC().Format(time.RFC3339)
LongVersion = fmt.Sprintf("syncthing %s (%s %s-%s) %s", Version, runtime.Version(), runtime.GOOS, runtime.GOARCH, date)
} }
var ( var (
@ -89,8 +93,7 @@ func main() {
} }
if showVersion { if showVersion {
date := BuildDate.UTC().Format(time.RFC3339) fmt.Println(LongVersion)
fmt.Printf("syncthing %s (%s %s-%s) %s\n", Version, runtime.Version(), runtime.GOOS, runtime.GOARCH, date)
return return
} }
@ -118,7 +121,7 @@ func main() {
log.SetPrefix("[" + myID[0:5] + "] ") log.SetPrefix("[" + myID[0:5] + "] ")
logger.SetPrefix("[" + myID[0:5] + "] ") logger.SetPrefix("[" + myID[0:5] + "] ")
infoln("Version", Version) infoln(LongVersion)
infoln("My ID:", myID) infoln("My ID:", myID)
// Prepare to be able to save configuration // Prepare to be able to save configuration