From 530097fe60c3d9feffabf52ea910bf35af9da6fb Mon Sep 17 00:00:00 2001 From: Jay Conrod Date: Thu, 13 Jun 2019 19:56:37 -0400 Subject: cmd/go: document GOBIN and 'go install' locations * In doc/install-source.html, clarify the meaning of $GOBIN and describe where executables from the Go distribution are installed. Also describe $GOPATH, since it provides a default value for $GOBIN and may conflict with $GOROOT. * Add more detail to 'go help install' as well. Fixes #31576 Change-Id: Ib8a8c21677c3aa0ebef97a3b587b6f8fe338b80e Reviewed-on: https://go-review.googlesource.com/c/go/+/182341 Run-TryBot: Jay Conrod TryBot-Result: Gobot Gobot Reviewed-by: Bryan C. Mills --- src/cmd/go/alldocs.go | 9 +++++++++ src/cmd/go/internal/work/build.go | 9 +++++++++ 2 files changed, 18 insertions(+) (limited to 'src') diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index df6b9e3e5d..d2ce578564 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -674,6 +674,15 @@ // // Install compiles and installs the packages named by the import paths. // +// Executables are installed in the directory named by the GOBIN environment +// variable, which defaults to $GOPATH/bin or $HOME/go/bin if the GOPATH +// environment variable is not set. Executables in $GOROOT +// are installed in $GOROOT/bin or $GOTOOLDIR instead of $GOBIN. +// +// When module-aware mode is disabled, other packages are installed in the +// directory $GOPATH/pkg/$GOOS_$GOARCH. When module-aware mode is enabled, +// other packages are built and cached but not installed. +// // The -i flag installs the dependencies of the named packages as well. // // For more about the build flags, see 'go help build'. diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go index 9c03f0818d..ed5a149da3 100644 --- a/src/cmd/go/internal/work/build.go +++ b/src/cmd/go/internal/work/build.go @@ -404,6 +404,15 @@ var CmdInstall = &base.Command{ Long: ` Install compiles and installs the packages named by the import paths. +Executables are installed in the directory named by the GOBIN environment +variable, which defaults to $GOPATH/bin or $HOME/go/bin if the GOPATH +environment variable is not set. Executables in $GOROOT +are installed in $GOROOT/bin or $GOTOOLDIR instead of $GOBIN. + +When module-aware mode is disabled, other packages are installed in the +directory $GOPATH/pkg/$GOOS_$GOARCH. When module-aware mode is enabled, +other packages are built and cached but not installed. + The -i flag installs the dependencies of the named packages as well. For more about the build flags, see 'go help build'. -- cgit v1.3-5-g9baa