kdnotify/buildinfo/build.go

47 lines
889 B
Go
Raw Normal View History

/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package build
import (
"strings"
"golang.org/x/exp/slices"
)
var (
// Git tag of this binary
Version = "v0.0.0+devel"
// Git hash of this binary
CommitHash = "0000000000000000000000000000000000000000"
// Enabled features of this binary
Features = ""
knownFeatures = map[string]bool{}
)
// Get the short Git hash
func ShortHash() string {
return CommitHash[:7]
}
// Get list of features enabled
func FeaturesList() []string {
out := []string{}
active := strings.Split(Features, ",")
for feature, _ := range knownFeatures {
sy := "-"
if slices.Contains(active, feature) {
sy = "+"
}
out = append(out, sy+feature)
}
slices.Sort(out)
return out
}