-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add go1.12 versioning support #172
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
Are there more docs around how the main module version is populated?
I'm currently looking at: https://tip.golang.org/pkg/runtime/debug/#ReadBuildInfo
What happens when the master branch is built? Will "dev" be overwritten with the previous version number?
I like -ldflags="-X main.Version=$(git describe --tags)"
since git describe --tags
will only print the tag name if the tag commit is checked out. Otherwise, it prints the nearest tag with the number of commits between the tag and the commit hash. It'd be nice to continue to have this behavior.
This change does not intend to replace Unfortunately documentation on Here is a relevant issue regarding limited documentation: golang/go#29228. |
// +build go1.12 | ||
|
||
package main | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing import "runtime/debug"
Thanks for helping However, I'm going to hold off on merging this until there's more documentation around how I peeked at the It looks like there's also an issue for tracking how to use VCS to get the module's version, which we could then replace our usage of: |
With upcoming
go1.12
we can now embed version information withoutLDFLAGS
. This PR usesdebug.ReadBuildInfo()
to simplify versioning withgo get
.Here is a working example