godoc
and gotour
can be built and run from their respecitve source directory with go build
. What is the reason a gotour
binary created when one go get
it and that is not the case for godoc
.
[ user@pc:~/.gvm/pkgsets/go1.5.1/global ]
>> ls
[ user@pc:~/.gvm/pkgsets/go1.5.1/global ]
>> go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/user/.gvm/pkgsets/go1.5.1/global"
GORACE=""
GOROOT="/home/user/.gvm/gos/go1.5.1"
GOTOOLDIR="/home/user/.gvm/gos/go1.5.1/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT=""
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
[ user@pc:~/.gvm/pkgsets/go1.5.1/global ]
>> go get golang.org/x/tools/cmd/godoc
[ user@pc:~/.gvm/pkgsets/go1.5.1/global ]
>> ls
pkg src
[ user@pc:~/.gvm/pkgsets/go1.5.1/global ]
>> go get golang.org/x/tour/gotour
[ user@pc:~/.gvm/pkgsets/go1.5.1/global ]
>> ls
bin pkg src
[ user@pc:~/.gvm/pkgsets/go1.5.1/global ]
>> ls bin/
gotour
[ user@pc:~/.gvm/pkgsets/go1.5.1/global ]
>> cd src/golang.org/x/tools/cmd/godoc/
[ user@pc:~/.gvm/pkgsets/go1.5.1/global/src/golang.org/x/tools/cmd/godoc ]
>> go build
[ user@pc:~/.gvm/pkgsets/go1.5.1/global/src/golang.org/x/tools/cmd/godoc ]
>> ./godoc
usage: godoc package [name ...]
godoc -http=:6060
-analysis string
comma-separated list of analyses to perform (supported: type, pointer). See http://golang.org/lib/godoc/analysis/help.html
-ex
show examples in command line mode
-goroot string
Go root directory (default "/home/user/.gvm/gos/go1.5.1")
-html
print HTML in command-line mode
-http string
HTTP service address (e.g., ':6060')
-httptest.serve string
if non-empty, httptest.NewServer serves on this address and blocks
-index
....
Godoc is special as it is an official tool being part of the Go distribution.
So if you go get
godoc, the result binary will not be placed under $GOPATH/bin
where all other executables go, but under $GOROOT/bin
.
Gotour is not special in this way, so it gets installed into your $GOPATH/bin
.
And for those just want to install godoc
under $GOPATH
can do so:
1. Download, don't install:
$ go get -u -d golang.org/x/tools/cmd/godoc
2. Build binary to specific path:
$ go build -o $GOPATH/bin/godoc golang.org/x/tools/cmd/godoc