Hacker News new | ask | show | jobs
by ubavic 1099 days ago
I enjoy Go so much. It is almost perfect language for getting things done, but I still can't understand some design choices.

Does someone knows why Go uses env variables (like GOOS and GOARCH) instead command line arguments?

5 comments

Env vars make it easier to automate in CI. The actual script to build for each os/arch is the same but only the vars change. It's convenient. You can always prefix the command with the env vars on the same line if you want a one-liner.
It could make it easier for build systems to be multi platform. You don’t have to keep track of custom args and add them to every call, you can just set the environment once.
As a PL focused on building networking services across different arch and platforms if it was any different that’ll be the first thing to hate in go
I guess so you can configure them on e.g. a build server instead of tweak your build command, but then, neither is particularly portable.
I assume so that it can be sticky across invocations and is easy enough to debug using `go env`