News for hackers. Stuff that matters.
Re:Go += Package Versioning by Sir_Cmpwn on Tuesday February 20, 2018 @01:33PM (#16422642)
>End of GOPATH

Yes yes yes yes finally! This has been the #1 reason I've avoided Go for years and even my recent forays back into the language were only after I figured out some hacks that I could use to avoid it.

Re:Go += Package Versioning by warent on Tuesday February 20, 2018 @01:44PM (#16422773)
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.

Re:Go += Package Versioning by Sir_Cmpwn on Tuesday February 20, 2018 @01:46PM (#16422786)
I 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".
Re:Go += Package Versioning by dasacc22 on Tuesday February 20, 2018 @02:18PM (#16423186)
I'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.

Re:Go += Package Versioning by Groxx on Wednesday February 21, 2018 @12:14AM (#16427025)
This 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.
Re:Go += Package Versioning by neoasterisk on Wednesday February 21, 2018 @03:07AM (#16427784)
Dependency injection is very commonly used in the Go ecosystem. Do not confuse resistance about unidiomatic DI frameworks with resistance about DI itself.
Re:Go += Package Versioning by Groxx on Wednesday February 21, 2018 @09:25PM (#16434726)
Which 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

Even Glide, Godep, and Dep have several thousand. And those can barely claim "most", much less "very common".

Re:Go += Package Versioning by neoasterisk on Thursday February 22, 2018 @05:32AM (#16436629)
What 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-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.)

Re:Go += Package Versioning by Groxx on Thursday February 22, 2018 @04:49PM (#16441751)
Yeah, 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.

Re:Go += Package Versioning by stormbeta on Tuesday February 20, 2018 @01:58PM (#16422948)
gofmt, 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.

Re:Go += Package Versioning by slrz on Tuesday February 20, 2018 @10:20PM (#16426571)
But 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".

Re:Go += Package Versioning by __david__ on Tuesday February 20, 2018 @02:00PM (#16422963)
It'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.
Re:Go += Package Versioning by ovao on Tuesday February 20, 2018 @05:20PM (#16424793)
It’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.

Re:Go += Package Versioning by clinta on Tuesday February 20, 2018 @11:06PM (#16426762)
GOPATH was weird to get used to at first, but I gave in and I actually store all my projects, even non-go projects, in the same folder hierarchy now. It has made me much more organized. In fact here's a zsh function I have for cloning new projects into that structure. It makes my home directory much less of a mess.

  gclone() {
  		dir=$(echo $1 | sed 's/^http\(s*\):\/\///g' | sed 's/^git@//g' | sed 's/\.git$//g' | sed 's/:/\//g' )
  		git clone $1  "$HOME/src/$dir"
  		cd "$HOME/src/$dir"
  }
Re:Go += Package Versioning by jadeklerk on Tuesday February 20, 2018 @01:39PM (#16422710)
Because you didn't want to set an env var?
Re:Go += Package Versioning by lloeki on Wednesday February 21, 2018 @02:19AM (#16427550)
The problem is not the env var, because whether or not it was set or with a default value, you have to clone the project https://github.com/foo/bar.git at ~/go/src/github.com/foo/bar and name the imports github.com/foo/bar accordingly and run the go commands from there. I used to (automatically) just export GOPATH="${PWD}/.gopath" but this doesn't work anymore since 1.8 or 1.9.

People† at large just want to clone https://github.com/foo/bar.git wherever they see fit, like directly at ~/Workspace/bar, ~/work/bar, ~/projects/contrib/bar or even /tmp/bar.

† "People" includes CI systems that expect the typical "clone and cd straight into" thing to work, resulting in a lot of boilerplate and/or symlink hacks to work around such expectations.

Re:Go += Package Versioning by chimeracoder on Tuesday February 20, 2018 @01:51PM (#16422863)
> Because you didn't want to set an env var?

You haven't needed to set a GOPATH since 1.8, which was released over a year ago (we're now at 1.10). Since 1.8, the Go toolchain will use a default GOPATH; the environment variable is only needed as an override.

Re:Go += Package Versioning by merb on Tuesday February 20, 2018 @01:50PM (#16422837)
GOPATH has a default. Unix: $HOME/go Windows: %USERPATH%/go

but on ci servers it could be akward.

Re:Go += Package Versioning by ovao on Tuesday February 20, 2018 @01:40PM (#16422729)
For what reasons did you need to avoid it?
Re:Go += Package Versioning by eberkund on Tuesday February 20, 2018 @01:45PM (#16422775)
Some people want to store their projects in their own folder structure and not be forced to store it in the very weird way Go does it. I didn't avoid Go for this reason but I did find the whole Go workspace way it does things a big turnoff.
Re:Go += Package Versioning by fiatjaf on Tuesday February 20, 2018 @01:49PM (#16422826)
You say that because you have infinite filesystem space. I don't.
Re:Go += Package Versioning by Sir_Cmpwn on Tuesday February 20, 2018 @01:51PM (#16422852)
Though GOPATH avoids duplication, it's entirely possible to avoid duplication without GOPATH.
Re:Go += Package Versioning by Groxx on Wednesday February 21, 2018 @12:11AM (#16427012)
And downloading the full Git repository for every `go get` is frequently a far greater waste than even storing copies of all the versions you're currently using in all projects you work on.

GOPATH is unambiguously terrible.

Re:Go += Package Versioning by fiatjaf on Wednesday February 21, 2018 @08:57AM (#16429429)
you're right.