-
-
Notifications
You must be signed in to change notification settings - Fork 33
Description
Prerequisites
- I searched to see if the issue already exists.
Description
It would be quite useful to be able to add some 'ldflags` when building the binary. For example I usually add a version and commit hash variable to my programs which is updated when building rather than in the code. This is extremely useful for debugging.
An example of using ldflags
to set the commit global variable:
go build -ldflags "-X github.com/a/b/main.commit=$(git rev-parse --short HEAD)" .
Other tools like goreleaser also set some flags by default and allow you to customize them as I do with my notify-cli tool. This makes it so when I run notify --version
from a binary generated with goreleaser I get the following:
$ notify --version
Version: v0.0.8
Commit: a8982ead528a717a05415f5cef7d7448f5adc968
But with a binary from gobinaries:
$ notify --version
Version: unknown
Commit: unknown
I wonder if adding a config file like .gobinaries.yml
with the flags you want to set would be something you would welcome, if so I could help with a PR.