cmd/go: go install documentation is lacking; effect of $GOBIN underdocumented #31576
Labels
Documentation
Issues describing a change to documentation.
FrozenDueToAge
NeedsFix
The path to resolution is known, but the work has not been done.
release-blocker
Milestone
It's been a while since I had to fiddle with my dev setup but I recently created a new separate go repo in my home directory and it took me a while to untangle where which binaries got installed. Specifically when it comes to uses of
$GOBIN
for which the documentation is a bit vague. It says that if$GOBIN
is set, thego
command installs all commands there. Well, that's not what I am observing.I have no Go specific environment variables set but for
GOPATH
which is set to$HOME
. So noGOBIN
, orGOROOT
per the usual recommendation.In a brand-new local repo of the Go distribution, after running
make.bash
, the two toolsgo
andgofmt
are built and installed in$GOROOT/bin
where$GOROOT
is the repo directory (per documentation). It doesn't matter if$GOBIN
is set or not.go install
of a new "command", that is a main package under$GOROOT/src/cmd
, appears to be installed in$GOTOOLDIR
no matter if$GOBIN
is set or not.$GOTOOLDIR
is$GOROOT/pkg/tool/GOOS_$GOARCH
.Only for binaries (main packages) outside
$GOROOTsrc/cmd
does$GOBIN
apply: Those end up in$GOBIN
if it set, or inGOROOT/bin
if$GOBIN
is not set.(This is all based in empirical evidence, I haven't studied the code. Happy to be corrected if I got this wrong.)
The documentation should be more clear. Right now we have lists of environment variables and respective documentation which is referred to from various places but it's not consistent.
More generally, it would be useful to document the recommended basic dev setup for people who want to work on the std lib. Specifically, where what is installed. Note that
go help install
doesn't say anything about what "install" actually means or where things go. It refers togo help build
andgo help packages
which only makes things complicated.cc: @bcmills
The text was updated successfully, but these errors were encountered: