forked from Azure/azapi-lsp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.go
31 lines (25 loc) · 803 Bytes
/
version.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main
import (
"fmt"
goversion "github.com/hashicorp/go-version"
)
// To set this from outside, use go build -ldflags "-X 'main.version=$(VERSION)'"
var version string = "0.1.0"
// A pre-release marker for the version. If this is "" (empty string)
// then it means that it is a final release. Otherwise, this is a pre-release
// such as "dev" (in development), "beta", "rc1", etc.
var prerelease = ""
func init() {
// Verify that the version is proper semantic version, which should always be the case.
_, err := goversion.NewVersion(version)
if err != nil {
panic(err.Error())
}
}
// VersionString returns the complete version string, including prerelease
func VersionString() string {
if prerelease != "" {
return fmt.Sprintf("%s-%s", version, prerelease)
}
return version
}