Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is one area that the Go ecosystem leaves me wanting a bit more. Idiomatic Go says that my package should be go-gettable, which AFAIK just uses `go install` command after fetching dependencies.

Is there an idiomatic way to include build options/tasks, while remaining go-gettable?



You can use ldflags with go get

go get -u -ldflags "-X main.Version foo" github.com/influxdb/telegraf/cmd/telegraf


This doesn't affect `go get`. You can use the same options when fetching the package, setting the variable or leaving it as the default.

     go get -ldflags="-X main.Who CloudFlare" import/path/package


I guess that's pretty reasonable. Especially coupled with sensible defaults for your variables like "unreleased" in the article. If you're building for a release you're probably a lot more up-to-speed on the needs for a release build anyway.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: