Using Go on Windows, whenever I execute go run myprog.go
from the console, Go builds a new executable with a random name somewhere on my C drive.
Is there a way to configure it so it will always build the file to a specific location, and preferably to also avoid the randomness of the name? (i.e., always build to D:\Temp\LastBuild.exe).
I was able to find some info that did not help when doing go help run
and go help build
. The latter had an output flag -o outfile
but it is not accepted in go run
.
Any help is appreciated.
Do not use go run
. It's intended for quick testing out snippets of code the size of a single screenful of lines.
The working approach is
go build
it.If you write tests in parallel with the implementation (and you should), this changes to
go test
it.Please see this recent thread on the mailing list for more insight on the same subject.