aboutsummaryrefslogtreecommitdiff
path: root/internal/version.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/version.go')
-rw-r--r--internal/version.go28
1 files changed, 22 insertions, 6 deletions
diff --git a/internal/version.go b/internal/version.go
index 2ffd7c90..a9e245d4 100644
--- a/internal/version.go
+++ b/internal/version.go
@@ -1,6 +1,12 @@
package internal
-import "fmt"
+import (
+ "fmt"
+ "strings"
+)
+
+// the final version string
+var version string
// -ldflags "-X github.com/matrix-org/dendrite/internal.branch=master"
var branch string
@@ -16,12 +22,22 @@ const (
)
func VersionString() string {
- version := fmt.Sprintf("%d.%d.%d%s", VersionMajor, VersionMinor, VersionPatch, VersionTag)
- if branch != "" {
- version += fmt.Sprintf("-%s", branch)
+ return version
+}
+
+func init() {
+ version = fmt.Sprintf("%d.%d.%d", VersionMajor, VersionMinor, VersionPatch)
+ if VersionTag != "" {
+ version += "-" + VersionTag
}
+ parts := []string{}
if build != "" {
- version += fmt.Sprintf("+%s", build)
+ parts = append(parts, build)
+ }
+ if branch != "" {
+ parts = append(parts, branch)
+ }
+ if len(parts) > 0 {
+ version += "+" + strings.Join(parts, ".")
}
- return version
}