-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: default GOBIN to GOPATH[0]/bin when outside of GOPATH? #23439
Comments
Arguments of $ go get github.com/nats-io/go-nats-streaming
$ go install github.com/nats-io/go-nats-streaming/examples
$ or $ go build /go/src/github.com/nats-io/go-nats-streaming/examples/stan-pub.go |
Thanks @cznic for your comment. What I understand from documentation and implementation is that the name of the argument is
Notice there
If one Second suggestion, to This ticket is intended to fix the inconsistency in |
The use of GOPATH/bin only applies to packages stored in GOPATH. go install /other/file.go is not considered to be in any GOPATH, so it can only use GOBIN. In the long term, with modules, we expect that people will stop setting GOPATH and then GOBIN may be more important (or maybe it will increase pressure to default to GOPATH[0]/bin). |
FWIW I would put the examples in subdirectories and then you can |
Note that if we do make GOBIN effectively default to GOPATH[0]/bin, then we could make 'go env GOBIN' show that default. |
See also #29005. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@jayconrod, @matloob: I think we should address this in Go 1.15. The inability to rely on |
sounds good to me |
Change https://golang.org/cl/232017 mentions this issue: |
The CL has been abandoned, so I'm guessing that this won't get done for 1.17. Should we change the milestone to 1.18 or Backlog? |
Ah, should have changed that earlier. Moved to Backlog. |
I still feel the pain of #23439 (comment) regularly when helping people relatively new to Go :) What was the work that https://go.dev/cl/232017 was missing to be finished? Perhaps with that information, someone else with a bit of experience in cmd/go could pick up the patch. |
From what I can tell, the remaining issues were described in this comment: |
This may be an infeasible approach, but... what about just teaching I imagine swapping the default internally too might be easier when we drop GOPATH mode entirely, which hopefully isn't too far away at this point. Two out of the four remaining issues that Jay mentioned are in GOPATH mode. |
I don't think a halfway approach in |
So it looks like this issue has been resolved, isn't it? What about going forward and exposing |
@dolmen This issue is still unresolved. We don't set On the other hand, I don't know if this issue is worth fixing at this point. It's not really a problem in module mode. Most users don't set (and shouldn't set) @dolmen What's the use case for your tool? Can you use the same logic we use? (use $GOPATH/bin unless $GOBIN is set) |
What version of Go are you using (
go version
)?1.9.2
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?Linux, amd64
What did you do?
What did you expect to see?
/go/bin/stan-pub
binary installed, consistent with the requirements whengo install <package>
is used, just GOPATH is set and that should be enough, GOBIN should not be required.What did you see instead?
Error message:
go install: no install location for .go files listed on command line (GOBIN not set)
The text was updated successfully, but these errors were encountered: