forked from hashicorp/terraform-ls
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decouple version into its own package
This allows us to import the package and use version elsewhere throughout the codebase and set the right version during the release via build flags.
- Loading branch information
1 parent
ee5c5ac
commit b3577e9
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package version | ||
|
||
import ( | ||
"fmt" | ||
|
||
version "github.com/hashicorp/go-version" | ||
) | ||
|
||
// The main version number that is being run at the moment. | ||
var Version = "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 = "dev" | ||
|
||
// SemVer is an instance of version.Version. This has the secondary | ||
// benefit of verifying during tests and init time that our version is a | ||
// proper semantic version, which should always be the case. | ||
var SemVer *version.Version | ||
|
||
func init() { | ||
SemVer = version.Must(version.NewVersion(Version)) | ||
} | ||
|
||
// ServerName is the name used to send to clients as a way | ||
// to identify itself in the LSP | ||
const ServerName = "hashicorp/terraform-ls" | ||
|
||
// String returns the complete version string, including prerelease | ||
func String() string { | ||
if Prerelease != "" { | ||
return fmt.Sprintf("%s-%s", Version, Prerelease) | ||
} | ||
return Version | ||
} |