move version info to separate package

This commit is contained in:
Christian Schwarz
2018-08-26 21:57:19 +02:00
parent ee5445777d
commit 428339e1ad
5 changed files with 35 additions and 28 deletions

31
version/version.go Normal file
View File

@ -0,0 +1,31 @@
package version
import (
"runtime"
"fmt"
)
var (
zreplVersion string // set by build infrastructure
)
type ZreplVersionInformation struct {
Version string
RuntimeGOOS string
RuntimeGOARCH string
RUNTIMECompiler string
}
func NewZreplVersionInformation() *ZreplVersionInformation {
return &ZreplVersionInformation{
Version: zreplVersion,
RuntimeGOOS: runtime.GOOS,
RuntimeGOARCH: runtime.GOARCH,
RUNTIMECompiler: runtime.Compiler,
}
}
func (i *ZreplVersionInformation) String() string {
return fmt.Sprintf("zrepl version=%s GOOS=%s GOARCH=%s Compiler=%s",
i.Version, i.RuntimeGOOS, i.RuntimeGOARCH, i.RUNTIMECompiler)
}