Closed Julio-Guerra closed 1 week ago
I am digging into the custom buildpack right now with a compile
script doing:
go install
the tool$buildpack_dir/export
script with the GOFLAGS
env var value to use.So that users should be able to use the default go buildpack + mine (first).
I am digging into the custom buildpack right now with a
compile
script doing:
go install
the tool- create the
$buildpack_dir/export
script with theGOFLAGS
env var value to use.So that users should be able to use the default go buildpack + mine (first).
FYI, this solution works: https://github.com/sqreen/heroku-buildpack-go/tree/master/bin
The only problem I foresee will be users compiling multiple Go binaries while not willing to use the tool on all of them, while GOFLAGS
makes the tool generally available.
I thinks it a good enough solution for me now, but adding the ability to customize the Go compiler flags for each Go build, directly in this buildpack would be better.
These are the flags that are currently sourced from the environment: https://github.com/heroku/heroku-buildpack-go/blob/289f452a803b671c74da32caa98c132037c55e2b/lib/common.sh#L208-L221
Adding the following would solve your problem (AFAICT): envFlags+=("GOFLAGS")
Maybe @danp or @heroku/languages are interested in doing so.
Hello,
I can't find any way of passing custom build flags to the Go compiler. I tried using the
GOFLAGS
environment withheroku config:set GOFLAGS="my extra flags"
but I doesn't work.Ideally, I need a solution to pre-install a tool that I pass to the compiler through its flags:
go install my-tool
go build <my options with my-tool> app
Is it possible? I will otherwise have to move to a Dockerfile solution for now. Or maybe should I create a separate buildpack for that :thinking: ?
For some context: I am the tool provider, willing to document the Heroku use-case ;-) Thanks!