简体   繁体   中英

go tool: no such tool "tour"

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

tour is not installed by default with an installation of go. You need to go get it:

go get golang.org/x/tour/gotour

Docs: https://github.com/golang/tour/

I had a problem too. This's my solution, on OSX let try

gotour

With version go1.8.1 darwin/amd64

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

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

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:

The correct way to get tour is:

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

reference

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/

https://github.com/golang/tour/blob/master/README.md

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/

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM