5 ms·
I've been programming in Go for a couple of years now and found that this need to use "hacks ... to avoid it" is totally naive and irrational. Agreed, GOPATH i
by warent 9y ago
I've been programming in Go for a couple of years now and found that this need to use "hacks ... to avoid it" is totally naive and irrational.
Agreed, GOPATH is awkward--at first. Because it's different from what most programmers are used to. But once it's adopted it actually makes a lot of sense, and looking back it seems bizarre to ever have such a strong desire to avoid it at all costs--and the costs are high.
The same applies for Gofmt as well.
- Sir_Cmpwn 9y agoI should add that another big part of the reason I've been avoiding the language for years is the cult of Golang telling me my complaints are "totally naive and irrational".
- dasacc22 9y agoI've been working with Go for 6 years, your complaints are not "totally naive and irrational". I don't mind GOPATH, but I did argue that if vendoring was to be a thing then it needed to be dropped entirely. I was also not a fan of the vendoring mechanism. The approach given here looks much more thought out getting rid of each, first proposal I've actually liked.
- Groxx 9y agoThis kind of attitude around package management and especially dependency injection have been major turn-offs for me as well. More than a sufficient number of the community has been emitting a high-pressure stream of NIH combined with ignorance of existing solutions, and it has been crippling the community for years.
- neoasterisk 9y agoDependency injection is very commonly used in the Go ecosystem. Do not confuse resistance about unidiomatic DI frameworks with resistance about DI itself.
- Groxx 9y agoWhich ones are common? I've been hoping this would be the case, but I've been unable to find evidence for it. e.g. the most-popular one I can see so far is Facebook's "inject", which has a remarkably small 841 stars: https://github.com/facebookgo/inject https://github.com/facebookgo/inject Even Glide, Godep, and Dep have several thousand. And those can barely claim "most", much less "very common".
- neoasterisk 9y agoWhat do you mean which ones? I am talking about dependency injection as a technique/pattern. In Go you can just do it without importing anything. Please read: https://medium.com/@benbjohnson/standard-package-layout-7cdbc8391fc1#db5a https://medium.com/@benbjohnson/standard-package-layout-7cdb... (I've linked to the exact point in the article where it talks about DI but you might want to read the rest as well.)
- Groxx 9y agoYeah, it's widespread as a hand-coded thing. It has to be - you essentially have no choice in Go for even basic things like tests. But that just means that everyone rolls their own thing by hand, with widely-varying feature-sets, method names, bugs, etc. DI frameworks are very much nicer for interop between a bunch of libs.
- stormbeta 9y agogofmt, sure. Consistency in style is great. But GOPATH was a mistake in the same way Go's hitherto lack of versioning was: it deliberately breaks easy isolation between projects / dependency management. This mindset only works if you control most of the ecosystem (such as with a monorepo), but it's a irritating mess otherwise.
- slrz 9y agoBut you do control all the source code within your GOPATH! It's right there on your file system. There's also a mechanism to take control of the same code even when it's outside your GOPATH. Github calls this mechanism a "pull request".
- __david__ 9y agoIt's really not irrational to want to organize my projects in a way other than by their (current) git repo URL. It's also not irrational to not want disparate projects to not share the same pool of dependencies (which even go has begrudgingly accepted as evidenced by "dep" and this proposal). Go is alright but I refuse to drink the GOPATH cool aid.
- ovao 9y agoIt’s totally reasonable to want to organize projects in a different way, but I think GOPATH’s caveats are overstated. - It’s an evironment variable, which makes it relatively easy to modify. To switch your dependencies from one pool to another, you can modify your GOPATH. - The vendor directory lets you pin your dependencies per-project without modifying GOPATH. It’s not the most beautiful solution (and Go doesn’t often offer the most beautiful solution to any particular thing), but it’s workable.