I’m just going to talk about installing Go on Mac OS X, because that’s the machine I have.
The actual installing couldn’t be simpler. If you visit http://golang.org/doc/install, you’ll see a nice friendly link to the Go Downloads page. You’ll see a batch of those which are for OS X 10.x+; choose the one that best fits the Mac you’re using. Choose the pkg download, unless you have some reason to want to install from source.
The pkg will open a typical Mac OS X installer wizard-style program, and it will install Go in
/usr/local/go, which is where Go expects to be found.[^1]
Go does expect a few environment variables to be set.
$GOROOT is set to
/usr/local/go by default, so you’d only need to change that if you installed Go in some non-standard location.
You’re not quite done. Go expects code to be organized in workspaces. All that means is you’ll want to create a directory for your Go work, and put your various Go projects inside it. Then Go needs to know where this workspace is.
For example, assuming you did
mdkir ~/go, you would put into
# for convenience:
A little more
Go also assumes that you’ll be working with projects stored in source control, and wants us to use the repository’s root as our base path. If I’m creating Go projects and planning to put them in my github.com account, I’ll want to put them in a structure like:
I’ll leave some basic _hello world_ing up to you; I would recommend going through How to write Go code. It shouldn’t take very long, you’re already set up.