Repository: go
Issue: cmd/go: misleading warning on GOROOT == GOPATH in module mode
Labels: NeedsFix,GoCommand,modules

### What version of Go are you using (`go version`)?

<pre>
go version go1.17 linux/amd64
</pre>

### Does this issue reproduce with the latest release?

Yes.

### What operating system and processor architecture are you using (`go env`)?

<details><summary><code>go env</code> Output</summary><br><pre>
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/usr/local/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/usr/local/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17"
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-build561180864=/tmp/go-build -gno-record-gcc-switches"
</pre></details>

### What did you do?

I was installing `go install github.com/golang/protobuf/protoc-gen-go@v1.5.2`.

Inside a fresh system I did:

```
$ curl -L https://golang.org/dl/go1.17.linux-amd64.tar.gz | tar -C /usr/local -xz
$ export GOPATH=/usr/local/go
$ export PATH="${GOPATH}/bin:${PATH}"
$ go install github.com/golang/protobuf/protoc-gen-go@v1.5.2
warning: GOPATH set to GOROOT (/usr/local/go) has no effect
go: downloading github.com/golang/protobuf v1.5.2
go: downloading google.golang.org/protobuf v1.26.0
$ ls -al /usr/local/go/bin
total 25120
drwxr-xr-x  2 root root     4096 Aug 22 14:11 .
drwxr-xr-x 10 root root     4096 Aug 16 16:27 ..
-rwxr-xr-x  1 root root 14007666 Aug 16 16:30 go
-rwxr-xr-x  1 root root  3318877 Aug 16 16:30 gofmt
-rwxr-xr-x  1 root root  8384142 Aug 22 14:11 protoc-gen-go
$ ls -al /root/go/bin
ls: cannot access '/root/go/bin': No such file or directory
```

In another fresh system I did:

```
$ curl -L https://golang.org/dl/go1.17.linux-amd64.tar.gz | tar -C /usr/local -xz
$ export PATH="/usr/local/go/bin:${PATH}"
$ go install github.com/golang/protobuf/protoc-gen-go@v1.5.2
go: downloading github.com/golang/protobuf v1.5.2
go: downloading google.golang.org/protobuf v1.26.0
$ ls -al /usr/local/go/bin
total 16932
drwxr-xr-x  2 root root     4096 Aug 16 16:30 .
drwxr-xr-x 10 root root     4096 Aug 16 16:27 ..
-rwxr-xr-x  1 root root 14007666 Aug 16 16:30 go
-rwxr-xr-x  1 root root  3318877 Aug 16 16:30 gofmt
$ ls -al /root/go/bin
total 8196
drwxr-xr-x 2 root root    4096 Aug 22 14:14 .
drwxr-xr-x 4 root root    4096 Aug 22 14:14 ..
-rwxr-xr-x 1 root root 8383846 Aug 22 14:14 protoc-gen-go
```

### What did you expect to see?

As you see, setting `GOPATH` is critical for getting binary installation into `/usr/local/go/bin` instead of `/root/go/bin`. Without it, it does not work. So the warning saying `GOPATH set to GOROOT (/usr/local/go) has no effect` is misleading. Setting `GOPATH` has a pretty dramatic effect.

### What did you see instead?

I have seen the warning saying `GOPATH set to GOROOT (/usr/local/go) has no effect` and I assumed I can just remove setting `GOPATH` but it turns out that is not true. It has an effect.

I think this is important because [installation instructions](https://golang.org/doc/install) only talk about setting `export PATH=$PATH:/usr/local/go/bin`, but without setting `GOPATH`. So installed binaries go into `/root/go/bin` which is not in `PATH` based on the installation instructions.