mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 14:50:55 +03:00
add version info
This commit is contained in:
35
utils/version.go
Normal file
35
utils/version.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package utils
|
||||
|
||||
var (
|
||||
version = "0.9.0-dev"
|
||||
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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user