Closed oliverpool closed 2 years ago
Instead of using go run
, why not just go install && gokr-packer
?
If you absolutely want to use go run
, can you use its -exec
flag to specify a wrapper that applies environment variables?
I’d like to avoid adding a custom way to pass environment variables.
Instead of using
go run
, why not justgo install && gokr-packer
?
Because I wasn't able to find gokr-packer
afterwards :see_no_evil: it is actually simply in $(go env GOPATH)/bin/gokr-packer
...
(and it seems faster than go run
)
Currently build variables like GOARM, GOOS and GOARCH are simply forwarded from the current environment with some default values: https://github.com/gokrazy/tools/blob/7f0229b37ad1164487e56cb6e73a4d387db96183/cmd/gokr-packer/gotool.go#L15-L28
However this does not play well with
go run
:Since
GOARCH
will be used bygo run
, the resultinggokr-packer
executable will not run on and amd64 machine for instance.I would like to be able to use
go run github.com/gokrazy/tools/cmd/gokr-packer
, so that thegokr-packer
version can be managed bygo.mod
using atools.go
file:Here are the possible solutions to this problem, that I thought of:
GOKR_GOARCH= go run ...
for instance (which would override `GOARCH)go run .../gokr-packer -buildenv=env
withenv
being a file like:What do you think would be the most elegant way to fix this issue ? I can then try to craft a PR.