go tool: no such tool "tour"
MacosGoMacos Problem Overview
I'm trying out Go for the first time. I was following these docs and wanted to run the go tour locally, but I haven't figured out how to get it to work.
Where is the tool "tour" supposed to be found?
I'm on OSX 10.11.3, and I installed Go via Homebrew
my Go entries in .zshrc
export GOPATH=$HOME/code/Go
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
Macos Solutions
Solution 1 - Macos
tour
is not installed by default with an installation of go. You need to go get
it:
go get golang.org/x/tour/gotour
Solution 2 - Macos
I had a problem too. This's my solution, on OSX let try
gotour
With version go1.8.1 darwin/amd64
Solution 3 - Macos
It works for me using go1.4, but not with go1.7. If you just run go tool
, it gives you a list of known tools. They seem to have removed it from tools.
$ gvm use go1.7
$ go tool
addr2line
api
asm
cgo
compile
cover
dist
doc
fix
link
nm
objdump
pack
pprof
trace
vet
yacc
$ gym use go1.4
$ go tool
6a
6c
6g
6l
addr2line
cgo
cover
dist
fix
nm
objdump
pack
pprof
tour # <--- here
vet
yacc
Solution 4 - Macos
Firstly, it is no longer gotour
. And secondly, for the time being, the tour package is located at: golang.org/x/website/tour
as opposed to what A Tour of Go Welcome Page says.
So, at least for now:
get
tour is:
The correct way to go get golang.org/x/website/tour
Or,
go install golang.org/x/website/tour@latest
After which you can run the command in the terminal:
$ tour
2021/06/22 17:46:48 Serving content from /home/user/go/pkg/mod/golang.org/x/website/tour@v0.0.0-20210616181959-e0d934b43647
2021/06/22 17:46:48 A browser window should open. If not, please visit http://127.0.0.1:3999
2021/06/22 17:46:52 accepting connection from: 127.0.0.1:33192
To find out where it has been installed, you can do which tour
:
$ which tour
/home/user/go/bin//tour
Solution 5 - Macos
I've got: > golang.org/x/tour/gotour has moved to golang.org/x/tour
So, this works for me:
go get golang.org/x/tour
then:
tour
Solution 6 - Macos
Because of changes in Go package management and introduction of modules, this has changed since the original question. Thus, for future reference (as this is the first Google result), if you have not configured GOPATH environment variable
go get golang.org/x/tour
$HOME/go/bin/tour
Note that the executable is called "tour" instead of "gotour".
Source (with full explanation of why and details): https://stephencharlesweiss.com/getting-going-with-golang/
Solution 7 - Macos
When you install go, tour
is not installed by default. You need to do a go get golang.org/x/tour/gotour
. This downloads gotour
in your workspace.
If you configured your PATH properly, gotour
command from anywhere in the terminal will open up your browser, but if PATH is not configured properly, do a
$GOPATH/bin/gotour
This command can be used from anywhere in your command line and it opens tour in your default browser
http://whipperstacker.com/2015/09/27/how-to-run-the-go-tour-locally/
Solution 8 - Macos
Once gotour
is installed, it’s executable like other executables are typically stored in the bin
directory of your workspace. Inside the bin
directory ./gotour
will invoke or start gotour
, elsewhere the gotour
will need to be preceded by a path to where the executable is located. In other words $GOPATH/bin/gotour
will invoke or start gotour
when you are not inside the bin
directory.