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.
Prior to this change, gomacro was unable to report its own version.
I found myself reaching for the version when experimenting with my own changes, so I added a
--version
.This change introduces the cmd.Version package variable and Cmd.Version method, together these print the binary's version, which can be injected at build time. The
-V
and--version
options are now recognised by the cmd.Main method and these options, as well as-h
and--help
, short-circuit all other options on the command line. This avoids evaluating any possible expressions and the like if the user just wants a quick version or usage message.When I install the binary from source I now use:
And that produces:
I don't know if you've thought much about setting up a release process. I've heard that
go get
doesn't work with go modules (not sure where I heard that, but it works for me). In the past I've done this sort of thing: https://www.devroom.io/2015/10/12/building-golang-cli-tools-update/. And goreleaser looks interesting...You can even pass build flags to
go get
(which seems weird to me), so you could update the install instructions to:But if you ask me I think it would be nice to use goreleaser instead... I'd be happy to explore it in more detail if you think it's worthwhile. Not that your intended audience needs easy access to a binary, presumably a user won't be installing gomacro and not have go installed already...
Perhaps the hardcoded value should be
"v2.7"
instead of"latest"
(and you can bump it when you decided to bump the tag)?Sorry, for for the meandering train of thought here; anyway, I hope you like this idea :)