News for hackers. Stuff that matters.
Re:Ask HN: Which are the best Go repositories to read to lea... by nemo1618 on Sunday January 17, 2021 @12:09PM (#25812414)
The best Go source code is the stdlib. When you read stdlib code, you can be confident that nothing is there by accident. Every decision was made for a reason. When you're learning, that's invaluable, because it means you can "dig" anywhere and be rewarded for it, whereas "digging" into most codebases will often be a waste of time.

Also, I would advise actively avoiding the big names you have heard of. A lot of products are successful despite having garbage code. And even more of them are successful despite having only decent code, full of stuff not worth emulating.

Try to identify people who have a lot of experience and a strong command of the language, then look at their most recent projects.

Re:Ask HN: Which are the best Go repositories to read to lea... by sagichmal on Sunday January 17, 2021 @01:21PM (#25813283)
The stdlib is kind of a mess. One kitchen, many cooks, and everyone was learning how to put a five-course meal together as they went. There are some great bits -- package io and ioutil, for example -- but a lot of it is full of what we now understand are bad ideas, and the compatibility promise prevents anyone from doing anything about it.

There is much better code to read. I second the recommendation of HashiCorp's stuff. Stay away from Docker and especially Kubernetes.

Re:Ask HN: Which are the best Go repositories to read to lea... by earthboundkid on Sunday January 17, 2021 @05:59PM (#25816142)
FYI, ioutil is deprecated in Go 1.16. :-) They copied everything out of it and into io and os. It’s much cleaner actually once you get used to it.
Re:Ask HN: Which are the best Go repositories to read to lea... by maerF0x0 on Sunday January 17, 2021 @08:22PM (#25817182)
Another reason it is a bit of a mess is because of the no breaking changes promise. They have to keep ugly or deprecated interfaces unchanged, even into Go 2, iirc.
Re:Ask HN: Which are the best Go repositories to read to lea... by geoah on Sunday January 17, 2021 @02:52PM (#25814265)
Couldn't agree more. Cheney's response to why that is was "do as we say, not as we do".
Re:Ask HN: Which are the best Go repositories to read to lea... by wbl on Sunday January 17, 2021 @04:03PM (#25814933)
Do you have source / more details? There certainly are a few warts but overall it gets the job done.
Re:Ask HN: Which are the best Go repositories to read to lea... by thinkingkong on Sunday January 17, 2021 @12:22PM (#25812599)
The stdlib is the best for clarity. But there are some excellent examples of how to structure projects depending on what you're trying to build. Mat Ryer gave an excellent talk on writing HTTP Services. If you want a good example on how to write distributed systems then Hashicorps' projects are more or less gorgeous.

https://medium.com/@matryer/how-i-write-go-http-services-aft...

https://github.com/hashicorp

Re:Ask HN: Which are the best Go repositories to read to lea... by nemo1618 on Sunday January 17, 2021 @02:00PM (#25813720)
> Hashicorps' projects are more or less gorgeous

Is there a particular piece of code (as in, a single package/file/function) that jumps out to you as "gorgeous?" When I look at a random Hashicorp repo, it strikes me an impenetrable labyrinth.

Re:Ask HN: Which are the best Go repositories to read to lea... by aprdm on Sunday January 17, 2021 @05:36PM (#25815933)
Try to add a new feature or see how some feature works, with consul I did some greps over some features I used and followed the code.. was able to put a merge request upstream changing a behaviour I didn't like (configurable) within 4h (that didn't get accepted and that's OK)
Re:Ask HN: Which are the best Go repositories to read to lea... by alexeldeib on Monday January 18, 2021 @03:09AM (#25819407)
Re:Ask HN: Which are the best Go repositories to read to lea... by matwood on Sunday January 17, 2021 @01:13PM (#25813178)
To add to your point, Nic Jackson from hashicorp has a bunch of how-to videos and presentations that I've found good also.

https://www.youtube.com/channel/UC2V1SxXFUa5YxVJvTsrCgyg

Re:Ask HN: Which are the best Go repositories to read to lea... by bewuethr on Sunday January 17, 2021 @02:30PM (#25814026)
He also wrote a book: https://www.packtpub.com/product/building-microservices-with...

The book might be good, but my copy had a problem with spurious characters in every code block, but that seems to be fixed in later printings.

Re:Ask HN: Which are the best Go repositories to read to lea... by dastx on Sunday January 17, 2021 @03:13PM (#25814468)
Great resource! Thanks.
Re:Ask HN: Which are the best Go repositories to read to lea... by matwood on Sunday January 17, 2021 @01:21PM (#25813281)
> The best Go source code is the stdlib.

As a golang beginner, the go stdlib is one the most readable stdlibs I've read through. The combination of gofmt, manageable language features, and idiomatic ways to do things make most go code fairly easy to read.

I know go doesn't have a million language features, but readability after the fact is one of the benefits of this approach.

Re:Ask HN: Which are the best Go repositories to read to lea... by tonymet on Sunday January 17, 2021 @12:42PM (#25812831)
It’s also one of the more readable stdlibs. I use it for idioms and snippets .
Re:Ask HN: Which are the best Go repositories to read to lea... by phoinix on Sunday January 17, 2021 @04:27PM (#25815134)
I second that. Stdlib is great to get a feel how the language works. Some small programs are always the best, if they are written by a good programmer. A cli game i study right now but in Rust. A small program with a lot of logic, but without all the graphics distractions.

https://github.com/VladimirMarkelov/solkit