News for hackers. Stuff that matters.
Re:Go Modules in 2019 by cgag on Wednesday December 19, 2018 @11:38AM (#18716874)
Honestly I got the impression no one ever liked gopath.
Re:Go Modules in 2019 by tptacek on Wednesday December 19, 2018 @12:27PM (#18717363)
I hated it at first but came around over time, to the point where I haven't switched to the modules workflow yet.
Re:Go Modules in 2019 by kasey_junk on Wednesday December 19, 2018 @01:12PM (#18717817)
The modules workflow is a wreck currently. Defer a while if you can.
Re:Go Modules in 2019 by vhost- on Wednesday December 19, 2018 @01:30PM (#18718006)
care to explain why? I've been using it across all my projects just fine.
Re:Go Modules in 2019 by kasey_junk on Wednesday December 19, 2018 @01:49PM (#18718162)
My biggest complaints are when something goes wrong. It will frequently silently fail or act like it succeeded. Diagnosing these errors has been a major time sink since I started using it.

Next have been oddities with vendoring workflows. Given previous decisions it seemed like the golang team was driving towards vendored solutions but with go mod they seem to have backed off of that position. The workflows with go mod are clunkier & less well documented. Unfortunately I’m (and my teams) are highly invested in vendored libraries.

We’ve also had trouble with it not playing nice with dependencies that have not taken up modules (and some that are unlikely to).

That’s not even to mention my problem with their design or the hamfisted way they have gone about it, which is something I just have to get past.

Re:Go Modules in 2019 by cyphar on Wednesday December 19, 2018 @12:31PM (#18717438)
I think a primary problem with the modules workflow is that you can't switch to it until all Go projects you work on switch to it. Plus, all of us have got our own GOPATH home-directory workarounds so there's no real point in switching anymore.
Re:Go Modules in 2019 by atombender on Wednesday December 19, 2018 @03:26PM (#18719217)
That's not true at all. A Go-modules-enabled project can import packages from a non-modules-enabled project that doesn't have Go.mod in it. This was always the case with Glide and Dep, too.
Re:Go Modules in 2019 by cyphar on Thursday December 20, 2018 @01:52AM (#18722990)
That's not what I'm talking about. I'm talking about being able to build outside of GOPATH. This requires the top-level project to use go.mod and many don't (like Docker for instance).
Re:Go Modules in 2019 by atombender on Friday December 21, 2018 @09:17PM (#18738490)
But that's not the same thing. You don't have to switch all the projects you work on over to Go modules at the same time, only the projects you want to upgrade. It's entirely possible to migrate incrementally.
Re:Go Modules in 2019 by Merovius on Wednesday December 19, 2018 @06:15PM (#18720873)
> I think a primary problem with the modules workflow is that you can't switch to it until all Go projects you work on switch to it

It seems this gets fixed in Go 1.12 though. AIUI you'll be able to set GOMODULES=on, unset GOPATH and just continue working as before.

Re:Go Modules in 2019 by w8rbt on Wednesday December 19, 2018 @01:37PM (#18718065)
Same here. Will wait until Aug 2019 when I have to think about it.
Re:Go Modules in 2019 by zaphar on Wednesday December 19, 2018 @12:34PM (#18717466)
Pretty much every language has a GOPATH thing.

CLASSPATH, PYTHON_PATH, PERL5LIB, ...

I never really understand the hate here. It seems more like they didn't hate GOPATH specifically and more that they didn't like not having a package manager.

Re:Go Modules in 2019 by dagss on Wednesday December 19, 2018 @12:59PM (#18717705)
GOPATH behaves very, very differently from PYTHON_PATH and CLASSPATH, it is not the same thing at all.

Basically before go 1.11, it was impossible to just do

    git clone ... somedir
    cd somedir
    # build code and run something
You had to instead make sure "somedir" ended up somewhere within a particular deep directory structure. That is what people mean when they say "GOPATH".
Re:Go Modules in 2019 by Merovius on Wednesday December 19, 2018 @06:16PM (#18720885)
> Basically before go 1.11, it was impossible to just do

That's not true. It was always perfectly possible to do that, the code you build just couldn't import any libraries not installed in GOPATH. AIUI that is exactly the same as in other languages.

Re:Go Modules in 2019 by dagss on Thursday December 20, 2018 @02:56AM (#18723207)
Our git repo for a backend service contains dozens of packages, and many small packages is recommended in go, and they do need to import one another...

I guess it is not all that different from Python, with Python you need to add the source path to PYTHONPATH / sys.path (and often do so at runtime in the entrypoint script). With go you need the "src/github.com/dagss" prefix to the path. Or at least, according to conventions. You are right that it is more similar on a technical level than what I thought.

Re:Go Modules in 2019 by pjmlp on Wednesday December 19, 2018 @12:53PM (#18717653)
The ones listed by you apply mostly as library search path, while go compilers required GOPATH to point to the project being compiled.
Re:Go Modules in 2019 by kjksf on Wednesday December 19, 2018 @04:38PM (#18719948)
False.

You can put your code anywhere you want and `go build` and `go run` will work just fine.

It's only third party libraries that have to be in GOPATH, which is exactly a library (well, package) search path.

Re:Go Modules in 2019 by aeijdenberg on Wednesday December 19, 2018 @05:11PM (#18720258)
False only for very small values of code.

ie if your code itself is split into modules, they won't work (as they are imported by their full path, not relatively), and anything in your vendor dir is also ignored when used outside of a GOPATH entry.

Re:Go Modules in 2019 by mkozlows on Wednesday December 19, 2018 @01:03PM (#18717740)
Java, Perl, and Python all date back to the '90s. Yeah, that was a commmon pattern in the '90s.
Re:Go Modules in 2019 by revskill on Wednesday December 19, 2018 @12:06PM (#18717141)
Because setting environment variables is something most devs like to avoid.
Re:Go Modules in 2019 by cgag on Wednesday December 19, 2018 @12:16PM (#18717267)
No, because I have like 50 projects in ~/src and suddenly have to keep some of my code in ~/src/go/src/GitHub.com/cgag and that annoys me.
Re:Go Modules in 2019 by cyphar on Wednesday December 19, 2018 @12:22PM (#18717316)
I have tried several times to fix this problem in the past 5 or 6 years, once with symlinks (which would break quite often -- it's unsurprising that Plan 9 developers wouldn't care too much for handling symlinks correctly :P).

The current way I handle it is that $HOME/.local is my GOPATH, and $HOME/src links to $HOME/.local/src. So you can just have $HOME/src/github.com/bar/foo -- which is less ideal than just $HOME/src/foo, but it's something at least.

Re:Go Modules in 2019 by lenkite on Friday December 21, 2018 @03:56AM (#18732159)
I keep the source code for my projects in ~/src and I always set my GOPATH to my home dir. So the special 'go' in the path can be avoided. It will just be ~/src/github.com/...

But, yes, I rolled my eyes when learning about GOPATH for the first time.

Re:Go Modules in 2019 by revel on Wednesday December 19, 2018 @05:08PM (#18720236)
it's not just that large numbers of projects are a hassle, they make it harder to develop projects in isolation