I was following the http://tour.golang.org/ untill I got to the third step about that tells you that you can install the gotour on your system. After that I've installed the go language with brew by:
brew install hg
brew install go
Then I downloaded the gotour by:
go get code.google.com/p/go-tour/gotour
When I tried to launch the gotour it didnt recognise the command:
$ gotour
-bash: gotour: command not found
and
$ go gotour
and
$ ./gotour
So I tried to see the go path and it was empty,
echo $GOPATH
so I defined the GOPATH:
GOPATH=/usr/local/Cellar/go/1.0.2/src/pkg/code.google.com/p/
export GOPATH
Now I can run the gotour by runing
./gotour
But I'm insecure about my go enviroment.. wasn't I suposed to be able to run gotour by
go run gotour
or just by typing (like is described on this website http://www.moncefbelyamani.com/how-to-install-the-go-tour-on-your-mac/):
gotour
I would like to know if i'm doing things the right way since I'm new to the go programing language.
Following a mix of answers above, this is what worked for me on
OSX 10.12 (Sierra)
andGo v1.7.1
using Homebrew:I added this from Kosh's answer to my
.zshrc
or.bashrc
:Then in a new terminal window/tab:
I put this in my ${HOME}/.bash_profile
based on golfadas answer but updated to work with old and new versions of brew.
Installing go 1.4 with homebrew on OSX:
1) Create Directories
2) Setup your paths
3) Install Go
4) "go get" the basics
5) Start here: https://golang.org/doc/code.html at "your first program"
I think I have found the solution, I should have exported:
Instead of
Since thats where 'go get' puts the binaries (I guess). gotour is working:
Btw I based my answer on this post
http://code.google.com/p/go-tour/issues/detail?id=39 where they talk about exporting:
And the getting started page from go: http://golang.org/doc/install where they say you have to export:
I thing you should have set the GOPATH before you
go get
. Well, at least here in my machine this worked smoothly.I set the GOPATH to a folder in my home folder.
Hope this helps!
Just an update here - I ran into this same problem, and the previous answers did NOT help. On current (~1.2.2) versions of Go installed by Homebrew, you have to set GOROOT to the following:
export GOROOT=/usr/local/Cellar/go/1.2.2/libexec
I'm a little unfamiliar with the go folder structure, or changes to the go installation via homebrew, so I don't really know why. But - if you're missing what seems like all the core packages, the above should fix.