A library to make set/get/writing versioning information easier.
Use go get
:
go get -u github.com/tonglil/versioning
-
Add in
main.go
:var version string func init() { versioning.Set(version) }
-
Where you want to get the version:
version := versioning.Get() // or versioning.Write(os.Stdout)
-
Build your binary with this flag:
go build -ldflags "-X main.version=123-up-to-you"
Roadmap:
- Checking new versions
- Possibly use semver: https://github.com/hashicorp/go-version or https://github.com/blang/semver
- Self-upgrading binary