diff --git a/buildinfo/build.go b/buildinfo/build.go new file mode 100644 index 0000000..d5ff320 --- /dev/null +++ b/buildinfo/build.go @@ -0,0 +1,46 @@ +/* + * 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 +}