This repository was archived by the owner on Mar 27, 2024. It is now read-only.
version: Move vX.Y.Z to version.go so it works with go get, add git info#304
Merged
nkubala merged 1 commit intoGoogleContainerTools:masterfrom Apr 1, 2019
Merged
version: Move vX.Y.Z to version.go so it works with go get, add git info#304nkubala merged 1 commit intoGoogleContainerTools:masterfrom
go get, add git info#304nkubala merged 1 commit intoGoogleContainerTools:masterfrom
Conversation
… info Previously, building with `make` was required for `version` command to output v0.15.0; `go get` or `go build` would always tell you v0.0.0-unset. Now the basic vX.Y.Z is always available, and when building with `make` git information is appended: $ go run . version v0.15.0 built from git (unknown) $ out/container-diff version v0.15.0 built from git v0.15.0-1-gcd5a837-dirty
Contributor
Author
|
BTW, I don't think README says how to build from source, initially I didn't notice the Makefile and assumed |
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Followup from #293.
Previously, building with
makewas required forversioncommand to output "v0.15.0"; if you justgo getor clone andgo build .it would always tell you "v0.0.0-unset" :-(Now the basic vX.Y.Z is always available, and when building with
makegit information is appended:(I added
version --shortmode formake releaseto be able to extract the const embedded in version.go without anything else. IMHO that's cleaner than slicing the output ofversionbut could go either way.)Alternatives:
golang/go#22147, golang/go#29814 explore several directions for letting binaries know which git they were built from. ldflags is indeed main current way.
Most of these don't work with bare
go get.(
go generateis not an option as go get won't run it, it's intended for the author to run and commit)Go 1.12 has new
debug.ReadBuildInfo()api that's supposed to automagically provide build info without needing ldflags, but only if you use go modules (?) and people reported some issues using it: golang/go#29228. See also golang-migrate/migrate#172 for example attempt at using that.