News for hackers. Stuff that matters.
Re:Go: Ten years and climbing by kminehart on Thursday September 21, 2017 @10:32PM (#15309022)
I worry that a lot of developers who have been using languages like Java or C# see Go and immediately feel the need to point out that Go doesn't support language features that they've come to rely on, and so they see that as a weakness or a flaw.

With Go, you're getting a lot of high-level language features like anonymous functions, while also gaining the control that you're not able to get in higher level languages like Python or Ruby or Java.

I think this works out great for cloud computing, where performance is a major requirement, but the technology is expanding rapidly enough that a step up from C or C++ is very necessary.

A lot of the complaints I hear are related to abstractions, too, and I understand those to an extent. I also think that if you're complaining about the lack of generics, maybe you're not thinking about interfaces correctly. A perfect example is the beautiful simplicity that is the [`io.Reader`](https://medium.com/@matryer/golang-advent-calendar-day-seven...).

So, whenever someone says something like the OP:

> As a simple language to wire pieces together, Golang is fine, but it really doesn't give you the tools (imo) to be productive for anything more complex than simple apps.

I take that as meaning, "I've never seriously used Go beyond writing a hello world app. It doesn't have the features I rely on to be productive, therefore I don't think it's a capable language for larger projects."

I will say though, dependency management in Go is hell. I wish Go had something like Cargo.

Re:Go: Ten years and climbing by aphextron on Thursday September 21, 2017 @11:07PM (#15309147)
>I will say though, dependency management in Go is hell. I wish Go had something like Cargo.

This is the number one thing that has kept me from going full on Go. The killer feature of Node was NPM, not Javascript. Unless Golang comes up with something comparable it will forever remain niche.

Re:Go: Ten years and climbing by cloverich on Thursday September 21, 2017 @11:13PM (#15309157)
(NOTE: I am not a gopher) I thought godep was that? It's marked as suitable for production now, and I think official as of their next release.

https://github.com/golang/dep

Re:Go: Ten years and climbing by kminehart on Thursday September 21, 2017 @11:31PM (#15309217)
It is certainly a fantastic solution, and I definitely appreciate the work that Sam Boyer and the `dep` contributors do.

There's a lot of "gotya"s with using dep though.

One that gets me a lot is the fact that I like to commit my vendor folder, just for faster CI.

So if I committed my vendor folder with a copy of "k8s.io/client-go", and then in a different project I imported a package from my vendored project, it would never compile until I removed my local copy of that "vendor" folder, since it's looking for that specific dependency ("my-project/vendor/k8s.io/client-go").

Not sure if I explained that super well.

Re:Go: Ten years and climbing by infogulch on Friday September 22, 2017 @12:22AM (#15309380)
Ok, but why would you do that? Either just vendor it in the new project (copy-paste a directory) or download it to your gopath and import that. The nice thing is that you don't have to change the import when you decide to vendor.
Re:Go: Ten years and climbing by kminehart on Friday September 22, 2017 @02:37PM (#15314606)
I think you misunderstand.

If I have project A, which imports dependency A. I (for faster tests is the only real answer), decided to commit the vendor folder.

Now, in project B, if I import a package of project A, which uses dependency A, it will look for that specific version of dependency A. Specifically errors like this:

  pkg/projectb/example.go:18:30: cannot use *w (type "github.com/dependency/pkg".Example) as type "github.com/project/a/vendor/github.com/dependency/pkg".Example

It's not a big deal because if I just remove "github.com/project/a/vendor" from my $GOPATH then the problem is resolved.

because of this, I guess my real complaint here is that "vendor" doesn't seem to be the right word. I'm really just looking for something to complain about.

Re:Go: Ten years and climbing by infogulch on Friday September 22, 2017 @05:24PM (#15315938)
Oh I see. I think the conventional wisdom here is to only ever vendor the end use (binary) projects, not libraries (and maintain such a distinction). (But I guess that's as helpful as "you're holding it wrong".)

So your problem is you have ("binary") packages A and B, and a helper package at A/H that you want to import into B. But A is vendored at A/vendor, so A/H always looks for dependency D at A/vendor, which is wrong for B.

I would fix it by moving A's main into A/cmd, and vendor at A/cmd/vendor instead. A/cmd can still import all its' helper packages like before, but now B can also import them without getting snagged by A's vendoring because it vendors another level up.

Could that work?

Re:Go: Ten years and climbing by kminehart on Friday September 22, 2017 @07:55PM (#15317035)
Hmm yeah I think that would be a good option. One potential problem with that is running tests on the individual packages. I believe that the vendor folder would have to be in a descendant folder. So like... "./vendor", or "../vendor", "../../vendor", and so on. If the vendor folder was in "./cmd/vendor", and you ran the test "go test ./pkg/example", it would not find the vendor folder.

My solution was just to not commit the vendor folder, and before the test starts, run "dep ensure".

Re:Go: Ten years and climbing by infogulch on Friday September 22, 2017 @09:35PM (#15317500)
Oh that's certainly a good point and a deficiency in my design.

But then again if you're only testing H against A's vendored dependencies specifically, you're missing testing it against B's. I'm not sure how you would fix that.

Re:Go: Ten years and climbing by KishanB on Friday September 22, 2017 @01:21AM (#15309579)
I personally like glide more than godep
Re:Go: Ten years and climbing by naibafo on Friday September 22, 2017 @03:54AM (#15310173)
First a note, godep is a different tool then the one you mean [1], that does the same.

> dep still has nasty bugs, but in general these are comparable or fewer to other tools out there.

(From the Github readme)

I started a project about two months ago and wanted to use Dep, however there were a few show stopping issues for that. Most prominently Go has issues with upppercase/lowercase repositories, meaning if one of your dependencies imports github.com/Sirupsen/logrus, and you or another dependency imports github.com/sirupsen/logrus your code won't compile, no matter if you are on a case sensitive system or a case-insensitive system. [2] The aforementioned logger made a switch in the naming which caused problems while most were migrating the import. The docker distribution in its latest stable version still uses uppercase, while others use the lowercase.

Dep follows the Go specifications and at the moment just throws an error, before, they didn't handle it at all.

So I had to resort to a different dependency management for now, which did some linking to fix the situation.

[1]https://github.com/tools/godep [2]https://github.com/golang/dep/issues/1010

Re:Go: Ten years and climbing by pebers on Friday September 22, 2017 @05:11AM (#15310445)
AFAIK it's still not decided when/if it will join the main distribution.

I've not tried it for a while now but last I saw it was even more opinionated about GOPATH than the existing tooling, and it wasn't at all easy to figure out what it wanted me to do. Maybe it's improved since though.

Re:Go: Ten years and climbing by aphextron on Friday September 22, 2017 @12:08AM (#15309335)
>(NOTE: I am not a gopher) I thought godep was that? It's marked as suitable for production now, and I think official as of their next release.

I didn't realize they were working on solving this, that's fantastic. Hopefully it can gain traction.

Re:Go: Ten years and climbing by kminehart on Friday September 22, 2017 @02:38PM (#15314612)
github.com/golang/dep is actually an already fantastic (and official) solution.