I had the opportunity to use Golang in my business. I didn't touch it in earnest, so I tried to study by myself for the time being.
--For the time being, create hello.go
and try to display hello world.
$ go run hello.go
exec: "C:\\Users\\xxxxx\\AppData\\Local\\Temp\\go-build929698758\\b001\\exe\\hello": file does not exist
Ah? ?? what's this? Will you die in hello World? usually? That's why.
For the time being, just try build
xxxxx@xxx MSYS /c/Users/xxxxx/Documents/test/go
$ go build hello.go
xxxxx@xxx MSYS /c/Users/xxxxx/Documents/test/go
$ ls
hello hello.go
--Binary? Isn't windows! !!
If you run it on windows
$ ls
hello.exe hello.go
The correct answer is that you can do it ~
** The cause of this was the environment variable GOOS. ** **
$ env | grep GOOS
GOOS=linux
It was like this. This GOOS = linux
didn't work.
I didn't want to set it to texto during work.
If you set the environment variable GOOS = linux
, it seems that the binary file created by build
is created for Linux?
Can it be run on MSYS2
or git-for-windows
? I thought, but it was an error.
By the way
Change GOOS
$ export GOOS=windows
#If it is cmd,
set GOOS=windows
If you build after doing
hello.exe
will be generated.
This is the solution.
I don't know if it's correct to set GOOS = windows
.
Should I delete this environment variable already?
Recommended Posts