That is really unfortunate. Is there any alternative solution so that I can burn at least the version information to the binary when a user uses `go get`?
On Wednesday, November 25, 2020 at 6:36:17 PM UTC+1 Jan Mercl wrote: > On Wed, Nov 25, 2020 at 6:25 PM changkun <h...@changkun.de> wrote: > > > As far as I know, there are two approaches to add extra information at > build time: > > 1. using -ldflags="-X path/pkg.Var=${ENV_VAR}", in a Makefile > > 2. using `go generate ./...`, before `go build` > > > > These approaches are good as it is if I build my binary and distribute > it to other users. > > However, none of these are possible if a user uses `go get > github.com/user/pkg/cmd/x-cli` <http://github.com/user/pkg/cmd/x-cli>, > because: > > 1. `go get` does not understand Makefile > > 2. `go generate` does not execute with `go build` automatically. > > > > What should I do in order to plug the extra information (in my case, the > git version) if my user uses "go get"? > > I don't think that can be done. Also IINM, in module mode `go get` no > longer uses git. It just downloads the zipped version of the > appropriate tag via http from the hosting service. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/a628138a-cc0c-40db-afc4-141b14e3fbd1n%40googlegroups.com.