TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Which are the best Go repositories to read to learn the language?

199 pointsby Kreotikoover 4 years ago
I am looking for examples of open source projects showcasing best in class use of Golang. It doesn’t need to be the famous products we all know about.<p>I am looking at examples of real world professional usage for somebody already familiar with the language constructs and syntax.

19 comments

nemo1618over 4 years ago
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&#x27;re learning, that&#x27;s invaluable, because it means you can &quot;dig&quot; anywhere and be rewarded for it, whereas &quot;digging&quot; into most codebases will often be a waste of time.<p>Also, I would advise actively <i>avoiding</i> 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.<p>Try to identify people who have a lot of experience and a strong command of the language, then look at their most recent projects.
评论 #25813283 未加载
评论 #25812599 未加载
评论 #25813281 未加载
评论 #25812831 未加载
评论 #25815134 未加载
37ef_ced3over 4 years ago
Read the Go standard library, especially the parts written by Russ Cox. The parts written by Griesemer are less pleasant, no offense to him<p>But some of Go&#x27;s language decisions only become clear once you&#x27;ve written a lot of Go<p>For example, the &quot;var name = expr&quot; declaration form seems unnecessary in light of the short &quot;:=&quot; form but it is in the language to allow indented declaration blocks like this (where some variables get an initial value and some get just a type):<p><pre><code> var ( text []byte last int more = true ) ... </code></pre> I&#x27;ve been using Go for 3 years and the more Go I write, the more I appreciate it. Enjoy
评论 #25814023 未加载
pa7chover 4 years ago
I really enjoyed reading the upspin codebase. I thought it was really a clean design and clean code. Some of the early go team members were working on it including andrew gerrand and rob pike. I think its a bit of an experiment on how one might design a content sharing system if you were to start from the ground up and not on the current web standards. I particularly like how they work authentication and authorization into the model. I had a few experimental upspin services I wanted to write but never got around to.<p>Another great read for learning go that covers the more traditional challenges of standing up a basic web service with user accounts, testing, metrics, etc. is <a href="https:&#x2F;&#x2F;github.com&#x2F;benbjohnson&#x2F;wtf" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;benbjohnson&#x2F;wtf</a> and the accompanying blog posts that cover how to structure such an application and why.
stanislavbover 4 years ago
Hey mate. I built, recently, a service that tracks all repositories mentioned on HackerNews and Reddit. Based on that data you can see which are the most popular or talked about repos per language. I guess that can help you. e.g. <a href="https:&#x2F;&#x2F;www.libhunt.com&#x2F;lang&#x2F;go" rel="nofollow">https:&#x2F;&#x2F;www.libhunt.com&#x2F;lang&#x2F;go</a>
评论 #25816667 未加载
mbyioover 4 years ago
A lot of people are saying to read the stdlib, but the stdlib has a lot of objectively bad code in it. Some of it is necessary due to the nature of a standard library - you have extra concerns about dependencies to ensure people don&#x27;t have to include the entire stdlib in every binary. Some of it is stuff they hacked together when they were still designing the language, and that initial code still works fine so no need to update it.<p>I think the source code for pkg.go.dev is actually a treasure trove of good ideas and design patterns, especially if you are trying to make a small to mdedium sized web app (which, lets be real, is almost all web apps anyone will ever make). <a href="https:&#x2F;&#x2F;github.com&#x2F;golang&#x2F;pkgsite" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;golang&#x2F;pkgsite</a>
bilinguliarover 4 years ago
I also suggest reading: stdlib, projects by Rob Pike (Upspin), Andrew Gerrand, Brad Fitzpatrick, Dmitry Vyukov, Jaana Dogan, Jonathan Amsterdam.<p>Please avoid: Kubernetes, AWS code.<p>As a rule of thumb - less imports is better.
评论 #25816169 未加载
评论 #25814837 未加载
ValentineCover 4 years ago
I consider rclone one of my most used tools for managing data, and personally think it&#x27;s reasonably well-structured: <a href="https:&#x2F;&#x2F;github.com&#x2F;rclone&#x2F;rclone" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rclone&#x2F;rclone</a><p>I agree with the other commenters that stdlib is excellent for delving deep into the language.
marvinblumover 4 years ago
You can check out the Pirsch Analytics core [0]. I&#x27;m the maintainer and can answer all your questions :) It probably contains most features you&#x27;ll use when programming in Go. Take a look at the tracker.go for a concurrent collector. It also has a lot of parsing, a data model, database, http, public API, ... and UI is not required while learning Go I suppose.<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;pirsch-analytics&#x2F;pirsch" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;pirsch-analytics&#x2F;pirsch</a>
deepanchorover 4 years ago
I learned a lot from reading the Perkeep [1] codebase (formerly Calimstore). One of its core developers is Brad Fitzpatrick (former Golang team member) so you can be fairly confident it’s idiomatic Go.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;perkeep&#x2F;perkeep" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;perkeep&#x2F;perkeep</a>
tyingqover 4 years ago
I think LXD would be a good repo to look at. You would see examples of REST daemons, clustering, database access, auth, containers, etc. <a href="https:&#x2F;&#x2F;github.com&#x2F;lxc&#x2F;lxd" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;lxc&#x2F;lxd</a>
jszymborskiover 4 years ago
It&#x27;s no substitute for reading the code for a useful bit of software, but I always like to head over to <a href="https:&#x2F;&#x2F;learnxinyminutes.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;learnxinyminutes.com&#x2F;</a> to check out the short code examples&#x2F;overviews to get a feel for a language.
评论 #25814091 未加载
DerpyCoderover 4 years ago
I believe the best of the best use of Golang is being done by Dgraph.<p>They are the The world’s most advanced native GraphQL database with a graph backend.<p>Checkout their GitHub repo.<p><a href="https:&#x2F;&#x2F;dgraph.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;dgraph.io&#x2F;</a><p><a href="https:&#x2F;&#x2F;github.com&#x2F;dgraph-io&#x2F;dgraph" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dgraph-io&#x2F;dgraph</a>
aliyfarahover 4 years ago
I recommend the Mattermost server:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;mattermost&#x2F;mattermost-server" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mattermost&#x2F;mattermost-server</a><p>And I disagree with those that say stdlib is the best way of looking at the best Go code for two reasons:<p>1. A lot of times stdlib code is restricted to use only backward compatible code with old API contracts, some parts are neat but others are unwieldy. It&#x27;s a hit or miss.<p>2. Library code is different to application code. You can&#x27;t get as much variety in style, abstractions, design patterns in stdlib as you can in a real world application.<p>I reckon it&#x27;s important to read to get a whiff of succinct Go code, very good at learning protocols (like OAuth, Http etc) if you&#x27;re interested, but won&#x27;t be hugely helpful in building a CRUD app.
评论 #25831327 未加载
ximusover 4 years ago
I really enjoyed google&#x27;s <a href="https:&#x2F;&#x2F;github.com&#x2F;golang&#x2F;groupcache" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;golang&#x2F;groupcache</a>. Learned both about the language, and quality network application design, in a small package.
achiangover 4 years ago
I haven&#x27;t seen anyone recommend net&#x2F;http yet, but that is the library that was recommended to me to read to get a sense for modern, idiomatic go.
sneakover 4 years ago
I started trying to implement a basic example best practices (yet full featured, as a starting point for my own projects) go http server.<p>This is my result:<p><a href="https:&#x2F;&#x2F;git.eeqj.de&#x2F;sneak&#x2F;gohttpserver" rel="nofollow">https:&#x2F;&#x2F;git.eeqj.de&#x2F;sneak&#x2F;gohttpserver</a>
inancgumusover 4 years ago
Not a project per-se but a lot of small example projects: <a href="https:&#x2F;&#x2F;github.com&#x2F;inancgumus" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;inancgumus</a>
Antoninusover 4 years ago
thread from 2017: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=14462125" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=14462125</a>
JohnCClarkeover 4 years ago
The easiest way to learn golang is to sign up on HackerRank and try out their exercises. You can do it in-browser, so no need to even install the toolchain. You&#x27;ll learn faster by doing and reading in parallel.<p>To see examples of good source code just click thru the function names when searching the documentation. E.g. <a href="https:&#x2F;&#x2F;golang.org&#x2F;pkg&#x2F;net&#x2F;http&#x2F;#NewRequest" rel="nofollow">https:&#x2F;&#x2F;golang.org&#x2F;pkg&#x2F;net&#x2F;http&#x2F;#NewRequest</a> They link directly to the source code, and the standard library is extremely well commented.