1
0
mirror of https://github.com/drakkan/sftpgo.git synced 2025-11-23 22:04:50 +02:00
Files
sftpgo/utils/version.go
Nicola Murino 51aacae3c5 version: only git commit and build date must be modifiable
Improved some test cases too
2019-08-08 21:42:07 +02:00

37 lines
732 B
Go

package utils
const version = "0.9.0-dev"
var (
commit = ""
date = ""
versionInfo VersionInfo
)
// VersionInfo defines version details
type VersionInfo struct {
Version string `json:"version"`
BuildDate string `json:"build_date"`
CommitHash string `json:"commit_hash"`
}
// GetVersionAsString returns the string representation of the VersionInfo struct
func (v *VersionInfo) GetVersionAsString() string {
versionString := v.Version
if len(v.CommitHash) > 0 {
versionString += "-" + v.CommitHash
}
if len(v.BuildDate) > 0 {
versionString += "-" + v.BuildDate
}
return versionString
}
func init() {
versionInfo = VersionInfo{
Version: version,
CommitHash: commit,
BuildDate: date,
}
}