3 ms·
"Golang drops GOPATH" - I am waiting for this headline. The biggest hurdle with Golang and working on different unrelated projects that are in their own GIT re
by frik 9y ago
"Golang drops GOPATH" - I am waiting for this headline.
The biggest hurdle with Golang and working on different unrelated projects that are in their own GIT repo. Golang forces you to have one single path were all the code should reside - GOPATH. Name me one other language that has such a restrictive requirement. Why not offer a config?? Beside that I like everything else about Go a lot.
- rquirk 9y agoIn my project I use "env GOPATH=$PWD go ..." in the makefile, that way it all goes in the current directory. There's probably some good reason this is a bad idea, but go is kinda funky anyway so I make up my own best practices :-)
- petepete 9y agoHave a look at virtualgo https://github.com/getstream/vg https://github.com/getstream/vg
- jchw 9y agoThe GOPATH system blows for the learning curve, but it's good for a lot of other reasons, like being very simple to understand and reason about. I don't really enjoy the way Node.js and Python handle package management personally, because it can get complicated. But I've wondered why someone hadn't wired up Go with an npm style package manager, since it would totally be doable. The Go team does seem to care about the problem though, and they at least made a sane default Go path of $HOME/go, so you can go get right away.
- boomlinde 9y ago> The biggest hurdle with Golang and working on different unrelated projects that are in their own GIT repo. Golang forces you to have one single path were all the code should reside - GOPATH. No one forces you to have one single path where your code should reside. It's just an environment variable, so you can have a GOPATH set per project if you wish. It could be your git root. > Why not offer a config?? That's what they did, or what am I missing?
- justinclift 9y agoNot really. :) These are the Go .bashrc lines in my Linux dev desktop: export GOPATH=${HOME}/go:${HOME}/git_repos export GOBIN=${HOME}/git_repos/bin export PATH=$PATH:/usr/local/go/bin:${HOME}/go/bin:${HOME}/git_repos/bin Note the two different paths in GOPATH? ∙ $HOME/go is where "go get foo" puts stuff ∙ $HOME/git_repos is where stuff I'm developing goes (eg $HOME/git_repos/src/github.com/sqlitebrowser/dbhub.io) The separation means I can backup stuff I'm working on, and exclude the general downloaded Go code from backups as that would just be a waste of space. Most people do seem to use just one path in GOPATH though, and I remember also doing things that way when first starting out. Not sure why, maybe it's due to some incorrect assumptions given by the Go learning material commonly read when starting out?
- frik 9y agoGood idea, but it doesn't work for me. I can't understand the GOPATH restriction, I want to put the Go source code where I want. Think about the following projects (Win/Linux doesn't matter, I use both) One GOPATH doesn't work when you have several projects in different structures e.g. * D:\Projects\ABC\repo\server\go\src\ * D:\Projects\XYZ\git\backend\go\src\ * T:\svn\go\src\
- justinclift 9y agoYeah, I remember it was a pita for me to change my directory layout habits to work ok with Go. Maybe it'll become more flexible in future. :)
- slrz 9y agoRename Projects to "src" and set GOPATH to D:/.