Conversation
|
I like the idea of adding a command line option "--version". A mechanism to automatically inject the version numbers would be preferred, though: I want to keep the installation as simple as possible, and the current installation instructions |
ff4eff9 to
5c1e5dc
Compare
Prior to this change, gomacro was unable to report its own 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 releasing the binary, it should be built with something like:
go build -ldflags="-X github.com/cosmos72/gomacro/cmd.Version=$(git describe --dirty)" main.go
Signed-off-by: Corin Lawson <corin@responsight.com>
5c1e5dc to
eded6a9
Compare
|
I don't think a smudge filter will work because it would require the user to set it up prior to running Using I'd love to be wrong about smudge... I've never really understood how dirtying the working tree immediately on checkout is useful. I pushed one small amendment so that the hardcoded version is now |
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
-Vand--versionoptions are now recognised by the cmd.Main method and these options, as well as-hand--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 getdoesn'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 :)