You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
804 B
44 lines
804 B
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"runtime"
|
|
"text/template"
|
|
)
|
|
|
|
var (
|
|
// Version is version
|
|
Version = "0.0.1"
|
|
// BuildTime is BuildTime
|
|
BuildTime = "2019/04/03"
|
|
)
|
|
|
|
// VersionOptions include version
|
|
type VersionOptions struct {
|
|
GitCommit string
|
|
Version string
|
|
BuildTime string
|
|
GoVersion string
|
|
Os string
|
|
Arch string
|
|
}
|
|
|
|
var versionTemplate = ` Version: {{.Version}}
|
|
Go version: {{.GoVersion}}
|
|
Built: {{.BuildTime}}
|
|
OS/Arch: {{.Os}}/{{.Arch}}
|
|
`
|
|
|
|
func getVersion() string {
|
|
var doc bytes.Buffer
|
|
vo := VersionOptions{
|
|
Version: Version,
|
|
BuildTime: BuildTime,
|
|
GoVersion: runtime.Version(),
|
|
Os: runtime.GOOS,
|
|
Arch: runtime.GOARCH,
|
|
}
|
|
tmpl, _ := template.New("version").Parse(versionTemplate)
|
|
tmpl.Execute(&doc, vo)
|
|
return doc.String()
|
|
}
|
|
|