go build src code of `go doc`

43 views
Skip to first unread message

Gert

unread,
Jun 26, 2019, 4:39:22 PM6/26/19
to golang-nuts
Hmm trying to work on the src code of `go doc` but every time I try to compile a ./doc binary it uses other src code, it doesn't look in the current directory am in, I have to force it `go build main.go` what going on here? 

gert@gert ~/Desktop/go/src/cmd/doc:master> go build

gert@gert ~/Desktop/go/src/cmd/doc:master> ls
dirs.go         doc             doc_test.go     main.go         pkg.go          testdata

I can see a doc binary getting created but its not build form the main.go in current directory, I deliberately put a syntax error in main?

gert@gert ~/Desktop/go/src/cmd/doc:master> go build main.go 
# command-line-arguments
./main.go:78:2: syntax error: unexpected --, expecting }

gert@gert ~/Desktop/go/src/cmd/doc:master> go env
GOARCH="amd64"
GOBIN="/Users/gert/bin"
GOCACHE="/Users/gert/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/gert/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/gert/Desktop/go/src/cmd/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/dv/8tlwvjr91zjdyq4rk14lkkfm0000gn/T/go-build645754300=/tmp/go-build -gno-record-gcc-switches -fno-common"



Ian Lance Taylor

unread,
Jun 26, 2019, 6:11:58 PM6/26/19
to Gert, golang-nuts
This may be related to https://golang.org/issue/32724. Is your
cmd/doc directory underneath the directory displayed by `go env
GOROOT`?

Ian

Gert

unread,
Jun 26, 2019, 7:44:20 PM6/26/19
to golang-nuts
On Thursday, June 27, 2019 at 12:11:58 AM UTC+2, Ian Lance Taylor wrote:
Nope `~/Desktop/go/src/cmd/doc` (git clone of go itself) is not in GOROOT nor in GOPATH using a seperate bootstrap go version devel +f938b9b33b Wed Jun 26 20:26:48 2019 +0000 darwin/amd64 in /usr/local/go

So I assume if I match GOROOT with the repo as in git clone everything in /usr/local/go and bootstrap using a /usr/local/go1 then i can work on go doc. Going to try that now

Gert

unread,
Jun 26, 2019, 7:54:11 PM6/26/19
to golang-nuts
Yep working when I develop in GOROOT directly, but not sure if this intended by design that you can only develop on go src itself that way.

Ian Lance Taylor

unread,
Jun 26, 2019, 8:40:01 PM6/26/19
to Gert, golang-nuts
It is not intended. It is a bug.

It would be helpful if you could describe this on
https://golang.org/issue/32724. Thanks.

Ian
Reply all
Reply to author
Forward
0 new messages