how to pass "-ldflags" to a go language build.

Vick Khera vivek at khera.org
Mon Nov 21 20:13:24 UTC 2016


I'm looking at the port for net-mgmt/telegraf to see if we can have it
bake in the version number into the binary. Right now when you run
"telegraf -version" it just says literally "version". Apparently the
right way to set their version is to pass it to the command line like
this:

 go build -ldflags "-X main.version=$DISTVERSION" ...

How can I convince the Go ports infrastructure to pass this flag to
the right place? I don't see any obvious way in the Uses/go.mk file.

Similarly, the databases/influxdb port could use this treatment, so it
shows what version it is when you connect to it.

Thanks!


More information about the freebsd-ports mailing list