Looking into it it appears that there's active work in go/build.defaultGOPATH that makes returning an informative error message impossible.
This made sense when it was done in 428df5e39c0[1], but since then 57568958774[2] has gone in which changes the message from something that was useful to something that is now almost devoid of information. was: ``` go install: no install location for directory /home/user/src/path.org/to/package outside GOPATH For more details see: 'go help gopath' ``` now: ``` missing $GOPATH ``` ISTM that the warning provided before 428df5e39c0 is now the better option in terms of confusion. Perhaps that warning could be an error so that functional behaviour that exists now would remain, but with an actual explanation. Stopping with this error would be helpful: ``` warning: GOPATH set to GOROOT (/home/user/go) has no effect ``` [1]https://go-review.googlesource.com/c/go/+/33105/ [2]https://go-review.googlesource.com/c/go/+/118095/ On Fri, 2019-09-27 at 12:51 +0930, Dan Kortschak wrote: > Yes, that explains it. Perhaps the error could be more informative. > > On Thu, 2019-09-26 at 20:19 -0700, Ian Lance Taylor wrote: > > On Thu, Sep 26, 2019 at 7:36 PM Dan Kortschak <d...@kortschak.io> > > wrote: > > > > > > I am looking at some changes we have made to make code generation > > > independent of GOPATH since from the SettingGOPATH page of the > > > wiki > > > says "If no GOPATH is set, it is assumed to be $HOME/go on Unix > > > systems > > > and %USERPROFILE%\go on Windows." > > > > > > However, when I run `go env` I see `missing $GOPATH` in response. > > > > > > ``` > > > ~ $ go env > > > GO111MODULE="on" > > > GOARCH="amd64" > > > GOBIN="/home/user/bin" > > > GOCACHE="/home/user/.cache/go-build" > > > GOENV="/home/user/.config/go/env" > > > GOEXE="" > > > GOFLAGS="" > > > GOHOSTARCH="amd64" > > > GOHOSTOS="linux" > > > GONOPROXY="" > > > GONOSUMDB="" > > > GOOS="linux" > > > GOPATH="/home/user" > > > GOPRIVATE="" > > > GOPROXY="https://proxy.golang.org,direct" > > > GOROOT="/home/user/go" > > > GOSUMDB="sum.golang.org" > > > GOTMPDIR="" > > > GOTOOLDIR="/home/user/go/pkg/tool/linux_amd64" > > > GCCGO="gccgo" > > > AR="ar" > > > CC="gcc" > > > CXX="g++" > > > CGO_ENABLED="1" > > > GOMOD="/dev/null" > > > 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 -fmessage-length=0 -fdebug- > > > prefix- > > > map=/tmp/go-build038144482=/tmp/go-build -gno-record-gcc- > > > switches" > > > ~ $ unset GOPATH > > > ~ $ go env > > > missing $GOPATH > > > ``` > > > > > > Is this expected now? > > > > The problem you are encountering is that /home/user/go is already > > being used for GOROOT, so it can't be used for GOPATH. If the > > default > > location is unavailable, there is no fallback, so you get "missing > > $GOPATH". > > > > Ian > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/9e977076b90f6d1f0477f9dbc3ac48dc74bb9e69.camel%40kortschak.io.