Open
Description
What version of Go are you using (go version
)?
$ go version go version go1.15.3 linux/amd64
What did you do?
$ go env GOPROXY
https://proxy.golang.org,direct
$ go env GOSUMDB
sum.golang.org
$ go env GOPATH
/home/d630/go
$ go env GOBIN
$ go env GO111MODULE
$ go env GOTMPDIR
$
None of these envs are set specifically.
What did you expect to see?
I expect go env GOBIN
to be evaluated as <gopath>/bin
in a shell script.
What did you see instead?
go env GOBIN
is evaluated as blank.
Metadata
Metadata
Assignees
Type
Projects
Relationships
Development
No branches or pull requests
Activity
mvdan commentedon Nov 25, 2020
partially a duplicate of #23439.
jayconrod commentedon Nov 30, 2020
Closing as a duplicate of #23439.
For
GOBIN
, we'll likely fix #23439 after support for GOPATH builds is removed. In GOPATH mode, the logic that determines where binaries are installed whenGOBIN
is not set is surprisingly complicated. It depends on the location of the packages being installed within the root directories (GOROOT
andGOPATH
) as well asGOOS
,GOARCH
, and probably some other variables I'm forgetting.go env GOBIN
frequently won't give an accurate answer whenGOBIN
is not set.For
GO111MODULE
, the empty string is a valid value. In 1.15, it's equivalent toauto
. In 1.16, it's equivalent toon
.GOTMPDIR
probably could print a default, though I'm not sure if that would be useful in many cases.yaxinlx commentedon Nov 30, 2020
It is true that an empty string is a valid
GO111MODULE
value, just like empty strings forGOPATH/GOSUMDB/GOPROXY
. But the truth doesn't mean the inconsistency is a good design. I don't think it is harmful to letgo env GO111MODULE
returnauto
in go 1.15 andon
in 1.16 ifGO111MODULE
is not set (or always interpret a blankGO111MODULE
asauto
).Any harmfulness to make a consistency here?
jayconrod commentedon Nov 30, 2020
My interpretation of the issue was this was mainly about
GOBIN
. There's no harm in printing defaults for the other variables though. I'll reopen the issue.howjmay commentedon Dec 15, 2020
so should we simply print
GOBIN
as<gopath>/bin
jayconrod commentedon Dec 15, 2020
@howjmay It's more complicated than that: