{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/17271","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/17271/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/17271/comments","events_url":"https://api.github.com/repos/golang/go/issues/17271/events","html_url":"https://github.com/golang/go/issues/17271","id":179909759,"number":17271,"title":"proposal: incrementally modify the Go toolchain to work without GOPATH","user":{"login":"rasky","id":1014109,"avatar_url":"https://avatars3.githubusercontent.com/u/1014109?v=4","gravatar_id":"","url":"https://api.github.com/users/rasky","html_url":"https://github.com/rasky","followers_url":"https://api.github.com/users/rasky/followers","following_url":"https://api.github.com/users/rasky/following{/other_user}","gists_url":"https://api.github.com/users/rasky/gists{/gist_id}","starred_url":"https://api.github.com/users/rasky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rasky/subscriptions","organizations_url":"https://api.github.com/users/rasky/orgs","repos_url":"https://api.github.com/users/rasky/repos","events_url":"https://api.github.com/users/rasky/events{/privacy}","received_events_url":"https://api.github.com/users/rasky/received_events","type":"User","site_admin":false},"labels":[{"id":236419512,"url":"https://api.github.com/repos/golang/go/labels/Proposal","name":"Proposal","color":"ededed","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/30","html_url":"https://github.com/golang/go/milestone/30","labels_url":"https://api.github.com/repos/golang/go/milestones/30/labels","id":1373555,"number":30,"title":"Proposal","description":"Proposals that are pending (not yet accepted/rejected).\r\n","creator":{"login":"rsc","id":104030,"avatar_url":"https://avatars1.githubusercontent.com/u/104030?v=4","gravatar_id":"","url":"https://api.github.com/users/rsc","html_url":"https://github.com/rsc","followers_url":"https://api.github.com/users/rsc/followers","following_url":"https://api.github.com/users/rsc/following{/other_user}","gists_url":"https://api.github.com/users/rsc/gists{/gist_id}","starred_url":"https://api.github.com/users/rsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsc/subscriptions","organizations_url":"https://api.github.com/users/rsc/orgs","repos_url":"https://api.github.com/users/rsc/repos","events_url":"https://api.github.com/users/rsc/events{/privacy}","received_events_url":"https://api.github.com/users/rsc/received_events","type":"User","site_admin":false},"open_issues":228,"closed_issues":370,"state":"open","created_at":"2015-10-24T01:40:49Z","updated_at":"2018-02-20T23:55:15Z","due_on":null,"closed_at":null},"comments":60,"created_at":"2016-09-28T22:42:10Z","updated_at":"2018-02-21T11:38:02Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Over the years, when helping people approaching existing Go projects (colleagues, friends, etc.) the number one problem is of course that they don't know about `GOPATH`, they don't have one configured, and they expect to be able to clone an existing project wherever they want on the disk, and be able to build it. I think the problem statement is clear and the problem is well known.\n\nWith the introduction and adoption of the vendoring folder, most Go applications do not even require `go get` to run, after the initial clone: all the source code required to compile them is already available in the source tree; it's just that the Go tool doesn't know where to look if `GOPATH` is not defined.\n\nInstead of suggesting a default `GOPATH` (which does not solve the fact that people will need to find out about it and use it somehow), I suggest that we change the Go toolchain in multiple steps (each one can be independently released as an experiment):\n- **STEP 1**: If `GOPATH` is not set, the Go tool will use any existing `./vendor` directory as it was part of the `GOPATH`. (I think of this as defaulting `GOPATH/src` to `./vendor`).  At least `go build` and `go run` are guaranteed to work. Anything else, like `go install` and `go get`, would fail with an error pointing to the `GOPATH` documentation.  \n- **STEP 2**: if `GOPATH` is not set, the Go toolchain would be updated to use `$HOME/.gopkg` (or similar) as `pkg` directory. This would allow other commands to work (e.g.: `go build -i` or `go install`).\n- **STEP 3**: if `GOPATH` is not set, `go get` (or the new package manager, if/when it gets released) would be modified to download packages directly into `./vendor`\n\nAs shown in Step 2, I think this proposal would also interact well with the existing proposal/discussion of dropping `pkg` in favour of a hidden cache directory, as that would move things further into the direction of not needing `GOPATH` anymore for a whole class of development; in fact, this functionality could be prototyped in this specific scenario of \"`GOPATH` not defined\", where it would make sense to do it without facing the bigger discussion of deprecating `pkg` for a normal `GOPATH` scenario.\n\nAs shown in Step 3, I also think that this might interact well with the new package manager. I saw many people requested that the new package manager ought to be able to download dependencies directly into the vendor folder (like `govendor` and `glide` can do); if this functionality lands in the new package manager, it would be a perfect default for the \"`GOPATH` not defined\" scenario described here. Alternatively, it might make sense to discuss modifying `go get` to have this behaviour.\n\nI think this proposal is incremental, backward-compatible, doesn't affect existing users that successfully use `GOPATH`, and allow beginners to approach existing Go codebases without stumbling too soon into `GOPATH`.\n"},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/367299473","html_url":"https://github.com/golang/go/issues/17271#issuecomment-367299473","issue_url":"https://api.github.com/repos/golang/go/issues/17271","id":367299473,"user":{"login":"kardianos","id":755121,"avatar_url":"https://avatars2.githubusercontent.com/u/755121?v=4","gravatar_id":"","url":"https://api.github.com/users/kardianos","html_url":"https://github.com/kardianos","followers_url":"https://api.github.com/users/kardianos/followers","following_url":"https://api.github.com/users/kardianos/following{/other_user}","gists_url":"https://api.github.com/users/kardianos/gists{/gist_id}","starred_url":"https://api.github.com/users/kardianos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kardianos/subscriptions","organizations_url":"https://api.github.com/users/kardianos/orgs","repos_url":"https://api.github.com/users/kardianos/repos","events_url":"https://api.github.com/users/kardianos/events{/privacy}","received_events_url":"https://api.github.com/users/kardianos/received_events","type":"User","site_admin":false},"created_at":"2018-02-21T11:38:02Z","updated_at":"2018-02-21T11:38:02Z","author_association":"CONTRIBUTOR","body":"This issue will be resolved should vgo or similar solution be adopted. The need for a GOPATH env var goes away when adding a go.mod file with the module root path."}}
{"actor":{"display_login":"kardianos"}}