Skip to content

README: use $GOBIN instead of $GOPATH/bin#168

Merged
FiloSottile merged 1 commit intoFiloSottile:masterfrom
mvdan:master
Jun 12, 2019
Merged

README: use $GOBIN instead of $GOPATH/bin#168
FiloSottile merged 1 commit intoFiloSottile:masterfrom
mvdan:master

Conversation

@mvdan
Copy link
Copy Markdown
Contributor

@mvdan mvdan commented Jun 12, 2019

$GOPATH/bin works in the simple cases, but will break if the user
specifies their own $GOBIN, or if their $GOPATH has multiple elements.

This form is also simpler. Even if the user doesn't specify their custom
$GOBIN, 'go env GOBIN' will return the correct default.

$GOPATH/bin works in the simple cases, but will break if the user
specifies their own $GOBIN, or if their $GOPATH has multiple elements.

This form is also simpler. Even if the user doesn't specify their custom
$GOBIN, 'go env GOBIN' will return the correct default.
@FiloSottile FiloSottile merged commit ff17118 into FiloSottile:master Jun 12, 2019
@FiloSottile
Copy link
Copy Markdown
Owner

Thanks!

@dmitshur
Copy link
Copy Markdown

Even if the user doesn't specify their custom $GOBIN, 'go env GOBIN' will return the correct default.

@mvdan I can't reproduce this. Any ideas what's different about your setup such that you can?

~ $ go version
go version go1.12.6 darwin/amd64
~ $ echo $GOPATH

~ $ echo $GOBIN

~ $ echo $GO111MODULE

~ $ go env GOBIN

~ $ go env GOPATH
/Users/dmitshur/go
go env Output
~ $ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/dmitshur/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/dmitshur/go"
GOPROXY="https://proxy.golang.org"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/3m/rg2zm24d1jg40wb48wr0hdjw00jwcj/T/go-build792247979=/tmp/go-build -gno-record-gcc-switches -fno-common"

@mvdan
Copy link
Copy Markdown
Contributor Author

mvdan commented Jun 20, 2019

You're right, go env GOBIN doesn't print a default; I might have gotten confused. @FiloSottile feel free to revert this commit, though the old $GOPATH/bin approach is still broken for the two reasons I gave originally.

I think the only properly correct way is go list -f {{.Target}} some/main/package, which gives the path that a certain main package would be installed to. That might be overkill for the README - up to you.

FiloSottile added a commit that referenced this pull request Jun 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants