Install go with brew, and running the gotour

install go on mojave
install specific version of go
install go cli
brew install golint
go get not working mac
mac brew go install
mac brew update go
how to run golang

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.

Installing go 1.4 with homebrew on OSX:
1) Create Directories
mkdir $HOME/Go
mkdir -p $HOME/Go/src/github.com/user
2) Setup your paths
export GOPATH=$HOME/Go
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
3) Install Go
brew install go
4) "go get" the basics
go get golang.org/x/tools/cmd/godoc
5) Start here: https://golang.org/doc/code.html at "your first program"

Install go with brew, and running the gotour, 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. 1) Download the Go package installer for Mac OS X and install Go 2) Restart Terminal 3) Install Mercurial with Homebrew (if you don't have Homebrew installed, follow my guide for setting up a development environment on a Mac):

Following a mix of answers above, this is what worked for me on OSX 10.12 (Sierra) and Go v1.7.1 using Homebrew:

I added this from Kosh's answer to my .zshrc or .bashrc:

# Go development
export GOPATH="${HOME}/.go"
export GOROOT="$(brew --prefix golang)/libexec"
export PATH="$PATH:${GOPATH}/bin:${GOROOT}/bin"

test -d "${GOPATH}" || mkdir "${GOPATH}"
test -d "${GOPATH}/src/github.com" || mkdir -p "${GOPATH}/src/github.com"

Then in a new terminal window/tab:

$ brew install go
==> Downloading https://homebrew.bintray.com/bottles/go-1.7.1.sierra.bottle.tar.gz
Already downloaded: /Users/nigel/Library/Caches/Homebrew/go-1.7.1.sierra.bottle.tar.gz
==> Pouring go-1.7.1.sierra.bottle.tar.gz
==> Caveats
As of go 1.2, a valid GOPATH is required to use the `go get` command:
  https://golang.org/doc/code.html#GOPATH

You may wish to add the GOROOT-based install location to your PATH:
  export PATH=$PATH:/usr/local/opt/go/libexec/bin
==> Summary
🍺  /usr/local/Cellar/go/1.7.1: 6,436 files, 250.6M

$ go get golang.org/x/tools/cmd/godoc

$ go get github.com/golang/lint/golint

$ go get golang.org/x/tour/gotour

$ gotour
2016/10/19 12:06:54 Serving content from /Users/nigel/.go/src/golang.org/x/tour
2016/10/19 12:06:54 A browser window should open. If not, please visit http://127.0.0.1:3999
2016/10/19 12:06:55 accepting connection from: 127.0.0.1:52958

Install go with brew, and running the gotour, 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​  Installing gotour on OSX I recently started learning Go , and started out by following the tour on the golang site. The tour’s pretty good, and so when I left work and wanted to continue it on the train I decided to install it locally so I could work offline.

I think I have found the solution, I should have exported:

export PATH=$PATH:/usr/local/Cellar/go/1.0.2/bin/

Instead of

GOPATH=/usr/local/Cellar/go/1.0.2/src/pkg/code.google.com/p/
export GOPATH

Since thats where 'go get' puts the binaries (I guess). gotour is working:

$ gotour
2012/10/11 18:35:50 Serving content from /usr/local/Cellar/go/1.0.2/src/pkg/code.google.com/p/go-tour
2012/10/11 18:35:50 Open your web browser and visit http://127.0.0.1:3999/ 

Btw I based my answer on this post

http://code.google.com/p/go-tour/issues/detail?id=39 where they talk about exporting:

/usr/local/Cellar/go/1.0.2/src/pkg/code.google.com/p/

And the getting started page from go: http://golang.org/doc/install where they say you have to export:

export PATH=$PATH:/usr/local/go/bin

macos - Install go with brew, and running the gotour, 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​  First, on my Fedora system, even though I have installed Go 1.10.1 from binary rpms, running go tool tour doesn't work. The full paragraph says: To run the tour locally first download and install Go then start the tour from the command line: go tool tour. The two things go together: it's one sentence.

I put this in my ${HOME}/.bash_profile

export GOPATH="${HOME}/.go"
export GOROOT="$(brew --prefix golang)/libexec"
export PATH="$PATH:${GOPATH}/bin:${GOROOT}/bin"

test -d "${GOPATH}" || mkdir "${GOPATH}"
test -d "${GOPATH}/src/github.com" || mkdir -p "${GOPATH}/src/github.com"

based on golfadas answer but updated to work with old and new versions of brew.

How to install the Go Tour on your Mac, brew $ brew install mercurial # or brew install hg. 4) In Terminal, run the following command: $ sudo go get code.google.com/p/go-tour/gotour. Installing cmake with home-brew. after install run command like this "./ Install go with brew, and running the gotour. 352.

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!

Go, Go (golang programming language). Install Golang with Homebrew: $ brew update $ brew install golang. When installed, try to run go version to see the  To deploy tour.golang.org, run: GO111MODULE=on gcloud --project=golang-org app deploy --no-promote app.yaml This will create a new version, which can be viewed within the golang-org GCP project .

tour: go tool: no such tool "tour" · Issue #293 · golang/tour · GitHub, Context: https://tour.golang.org/welcome/3 I tried to run the go tour on my local, however, the command in the I installed go by brew install go . Test your installation. Check that Go is installed correctly by building a simple program, as follows. Create a file named hello.go that looks like: package main import "fmt" func main() { fmt.Printf("hello, world ") } Then build it with the go tool: $ go build hello.go C:\Users\Gopher\go\src\hello> go build hello.go

go tool: no such tool "tour" : golang, I was following these docs and wanted to run the go tour locally, but I haven't figured out how to get it to I'm on OSX 10.11.3, and I installed Go via Homebrew. (Note: Replace brew install hugo with brew install hugo --HEAD if you want the absolute latest version in development, but beware—there might be bugs!) Brew should have updated your path to include Hugo. Confirm by opening a new terminal window and running a few commands:

This means that gotour will be installed in /Users/you/code/go/bin, which is not in the list, and the computer comes up empty. You’ll get some sort of message saying that the command is not found. That’s fine.

Comments
  • Your GOPATH shouldn't be the same as your GOROOT. Set it to something like $HOME/go and add $GOPATH/bin to your PATH.
  • BTW the go tour get command and url now changed to: go get golang.org/x/tour/gotour
  • IntelliJ Idea not finding the GOPATH defined in your .bashrc? In step 2 paste the export lines in .bash_profile, not in .bashrc, restart your mac and IntelliJ will find GOPATH (just tested, reboot needed)
  • I automated the $GOPATH setup that you describe github.com/camilin87/setup_go
  • Why are you using $Home/Go with an uppercase G? The homebrew installer uses a lowercase G. E.g. ==> Caveats A valid GOPATH is required to use the `go get` command. If $GOPATH is not specified, $HOME/go will be used by default: https://golang.org/doc/code.html#GOPATH
  • This answer is super out of date and is causing a ton of issues given the changes to Go and it appears first on Google searches for "How to install Go using Brew". That means a lot of people are being directed to this outdated and inaccurate answer. You no longer have to set any paths for Go stackoverflow.com/a/21012349/3299397 and you only set GOROOT if you're developing the actual language Go (as in you make changes to Go's underlying code reddit.com/r/golang/comments/alrnuk/…)
  • This worked great for me on Sierra 10.12.5 with go 1.8.3. Thanks!
  • Worked for me on Catalina 10.15.2 with go 1.13.5 too. Thank you!
  • Continuing the trend, worked for me on Mojave 10.14.6 with go 1.13.8. I did modify this slightly though: when I export the path, I put the go paths at the front of $PATH rather than at the end. So the third line of my rc file looks like this: export PATH="${GOPATH}/bin:${GOROOT}/bin:$PATH"
  • This should be the accepted answer as it perfectly describes how to use it with homebrew!
  • I had to put an extra bin/ on the end, since it seems now that they put these go executables into a subdirectory now. I.e., the command for my path is: export PATH=$PATH:/usr/local/Cellar/go/1.3.3/bin/bin/
  • If you haven't installed it with brew but end up here because you can not run go when using zsh, you need to do very same stuff (exporting the path to your go installation). In my case it was: export PATH=$PATH:/usr/local/go/bin If it won't work for you, then you have it probably somwhere else installed.
  • This is the right advice. export GOPATH=$HOME/go and export PATH=$PATH:$GOPATH/bin covers all you need. Substitute $HOME/go for the path of your choice.
  • You could just uninstall your current go version and install the new one. That's what I did and everything worked just fine for me.
  • With homebrew you always should be using /usr/local/opt/ as the base. This way you don't even have to update the variable when a new version comes out.