如何更改默认路径以在Go编译器中存储可执行文件?

In Go compiler, when I do "go run", executable file is stored to a temporary location. How to change this path to store the file in current working directory? I am using windows 7 64bit machine.

If you want to do something with the binary beyond just running it once, you should be using go build, not go run. go build will put the binary in the current working directory.

I agree with @Adrian and @Saleem, however, for interest sake, you can override the location (somewhat) by changing the location of your environment variable TEMP (or TMPDIR on OSX or Linux). This will still create a temporary directory in whatever directory you specify, in which the working files will be placed. Keep in mind that as Adrian and Saleem say, go run is intended for temporary runs.

And of course @JimB beat me to it with his comment which is really the essence of what I'm saying here.

Agree with previous answers. go install saves binary file into GOBIN folder. So you may change it to have a specific location. However, I don't suggest to do it, because you can always build into specific folder using -o option of go build:

go build -o /usr/bin/app main.go