Just installed Go on Mac OS X, Yosemite Version 10.10.3, as explained in the Getting Started page of the official website:
Mac OS X package installer
Download the package file, open it, and follow the prompts to install the Go tools. The package installs the Go distribution to
/usr/local/go
.The package should put the
/usr/local/go/bin
directory in your PATH environment variable. You may need to restart any open Terminal sessions for the change to take effect.
I am now in the Test your installation section, which states:
Check that Go is installed correctly by building a simple program, as follows.
Create a file named
hello.go
and put the following program in it:package main import "fmt" func main() { fmt.Printf("hello, world ") }
Then run it with the go tool:
$ go run hello.go hello, world
If you see the "hello, world" message then your Go installation is working.
So, I created a hello.go
file and, since I could not (ie: did not know how to) access the /usr/local/go/bin
directory, I saved it on my desktop.
Obviously, I got the following error message:
stat hello.go: no such file or directory
So, where should I save my Go files to be able to run them?
UPDATE: after some research, I stumbled upond this video, explaining how to set the GOPATH.
If I want my Go workspace to be in user/code/go
, how should I write my export GOPATH=
command?