I'm cross compiling Golang programs on Windows for Linux, using:
go build -o myprog.bin myprog.go
To do so I have to set the environment variable GOOS=linux. As I'm also compiling some programs for windows, when I'm done with the cross compile I have to reset GOOS=windows. So I have a batch file as follows:
set GOOS=linux
go build -o myprog.bin myprog.go
set GOOS=windows
If I happen to be compiling two programs for each Linux and Windows simultaneously, the windows program may get compiled for Linux. Is there a way to limit the scope of an environment variable to a command on windows, or to override it for a command? eg
go build -o myprog.bin myprog.go -GOOS linux
I know goxc provides this, but can go build?