Files
sftpgo/utils/version.go
Nicola Murino ad53429cf1 add support for build tag to allow to disable some features
The following build tags are available:

- "nogcs", disable Google Cloud Storage backend
- "nos3", disable S3 Compabible Object Storage backends
- "nobolt", disable Bolt data provider
- "nomysql", disable MySQL data provider
- "nopgsql", disable PostgreSQL data provider
- "nosqlite", disable SQLite data provider
- "noportable", disable portable mode
2020-05-23 11:58:05 +02:00

52 lines
1.1 KiB
Go

package utils
import "strings"
const version = "0.9.6-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"`
Features []string `json:"features"`
}
// GetVersionAsString returns the string representation of the VersionInfo struct
func (v *VersionInfo) GetVersionAsString() string {
var sb strings.Builder
sb.WriteString(v.Version)
if len(v.CommitHash) > 0 {
sb.WriteString("-")
sb.WriteString(v.CommitHash)
}
if len(v.BuildDate) > 0 {
sb.WriteString("-")
sb.WriteString(v.BuildDate)
}
if len(v.Features) > 0 {
sb.WriteString(" ")
sb.WriteString(strings.Join(v.Features, " "))
}
return sb.String()
}
// AddFeature adds a feature description
func AddFeature(feature string) {
versionInfo.Features = append(versionInfo.Features, feature)
}
func init() {
versionInfo = VersionInfo{
Version: version,
CommitHash: commit,
BuildDate: date,
}
}