by Kreotiko on 1/17/21, 4:26 PM with 49 comments
I am looking at examples of real world professional usage for somebody already familiar with the language constructs and syntax.
by nemo1618 on 1/17/21, 5:09 PM
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.
by 37ef_ced3 on 1/17/21, 5:49 PM
But some of Go's language decisions only become clear once you've written a lot of Go
For example, the "var name = expr" declaration form seems unnecessary in light of the short ":=" 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):
var (
text []byte
last int
more = true
)
...
I've been using Go for 3 years and the more Go I write, the more I appreciate it. Enjoyby pa7ch on 1/17/21, 7:32 PM
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 https://github.com/benbjohnson/wtf and the accompanying blog posts that cover how to structure such an application and why.
by stanislavb on 1/17/21, 7:26 PM
by mbyio on 1/17/21, 10:55 PM
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). https://github.com/golang/pkgsite
by bilinguliar on 1/17/21, 7:41 PM
Please avoid: Kubernetes, AWS code.
As a rule of thumb - less imports is better.
by ValentineC on 1/17/21, 5:39 PM
I agree with the other commenters that stdlib is excellent for delving deep into the language.
by marvinblum on 1/17/21, 7:13 PM
by deepanchor on 1/17/21, 7:17 PM
by tyingq on 1/17/21, 5:41 PM
by jszymborski on 1/17/21, 5:02 PM
by DerpyCoder on 1/18/21, 6:29 AM
They are the The world’s most advanced native GraphQL database with a graph backend.
Checkout their GitHub repo.
by aliyfarah on 1/18/21, 5:58 AM
https://github.com/mattermost/mattermost-server
And I disagree with those that say stdlib is the best way of looking at the best Go code for two reasons:
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's a hit or miss.
2. Library code is different to application code. You can't get as much variety in style, abstractions, design patterns in stdlib as you can in a real world application.
I reckon it's important to read to get a whiff of succinct Go code, very good at learning protocols (like OAuth, Http etc) if you're interested, but won't be hugely helpful in building a CRUD app.
by ximus on 1/17/21, 11:42 PM
by achiang on 1/17/21, 11:18 PM
by sneak on 1/17/21, 10:37 PM
This is my result:
by inancgumus on 1/17/21, 9:55 PM
by Antoninus on 1/18/21, 5:33 AM
by JohnCClarke on 1/17/21, 5:50 PM
To see examples of good source code just click thru the function names when searching the documentation. E.g. https://golang.org/pkg/net/http/#NewRequest They link directly to the source code, and the standard library is extremely well commented.