Go (golang) is a programming language created by Google to solve the problem of exponential development effort needed to build large, backend systems.
It is a superb alternative for mainstream languages in any kind of Cloud Development. Currently often chosen as a replacement for Python or Node.js due lower costs (lower memory footprint, shorter execution times) in Microservices/Event-Driven Architecture/gRPC. But also shines in Serverless (where Java/C# runtime frameworks take their toil).
Characteristics of Go
- Based on the “Unix Philosophy”
- Promotes: simplicity, readability over cleverness, explicit over implicit (no magic)
- Solid foundation: Static Typing, compilation to native code (very fast), Garbage Collector
- Promotes one, idiomatic way of coding (so each codebase looks familiar; completely opposite to e.g. JavaScript or Scala)
- Composition over inheritance (literally; by embedding types)
- Don’t try to mimic mainstream languages in Go! There are no classes, and Go seems to be closer to Data-Oriented Programming than to OOP
Why
- Saving money. In Cloud you pay for memory⨯time. Go requires less of both
- Other languages are getting too bloated. Java’s spec has grown up to 750 pages, C#’s up to 517 pages. While Go’s language spec is only 50 pages long.
- Yet it turned out that clever language features and syntax sugar make it harder, not easier to maintain large codebases in the long run. (Think about it next time you see C#’s
{ get; set; } = default!idiom or the[NotNullWhen]attribute")
Adopted by
- Google (used on a massive scale), Microsoft (some internal Azure components), Facebook, CloudFlare, Paypal, Dropbox, Uber,… Allegro
- Stackoverflow survey shows 13% popularity level (a figure from 2023). In several years it surpassed all functional languages
- Known in DevOps world for years: Docker, Kubernetes, Terraform, Prometheus, K6 are pure Go projects
- Khan Academy migrated their platform (1M lines of code) from Python to Go (and although Go is much more verbose, codebase size increased only by 15%)
Preferred usage
- Backends, microservices, APIs, serverless, cloud native - Go is often called “the language of the cloud”
- CLIs, DevOps tools (tools compiled to a single executable, no runtime needed)
My proposed learning guide
Level 0
- An intro to Go for non-Go developers https://benhoyt.com/writings/go-intro/
- YouTube: “Simplicity is Complicated”, Rob Pike https://youtu.be/rFejpH_tAHM
- Official “Tour of Go” https://go.dev/tour/
- YouTube: Opening Keynote by Rob Pike (history of how go was created) https://youtu.be/VoS7DsT1rdM
Level 1
- YouTube: “Go Proverbs” https://go-proverbs.github.io/ + https://youtu.be/PAAkCSZUG1c
- Effective Go - https://go.dev/doc/effective_go (an important source on how to write idiomatic Go code)
- Errors are values blog post https://go.dev/blog/errors-are-values
- Go by Example https://gobyexample.com/
- Cheatsheet https://github.com/a8m/golang-cheat-sheet ; Or https://devhints.io/go
Level 2
- “Essential Go” (a free, online ebook. Comprehensive yet compact, imho one of the best free resource for devs who know other - languages): https://www.programming-books.io/essential/go/
- Thoughtworks’s “Go interfaces: Mistakes to avoid when coming from an Object-Oriented language” https://www.thoughtworks.com/insights/blog/programming-languages/mistakes-to-avoid-when-coming-from-an-object-oriented-language
- Browse official “Go Learn” https://go.dev/learn/ Exercism Go track (interactive exercises to train a bit) https://exercism.org/tracks/go
Level 3
- YouTube: “The Zen of Go”, Dave Cheney https://youtu.be/yd_rtwYaXps
- YouTube: “Golang: The good, the bad, & the ugly”, Vincent Batts - https://youtu.be/cMYhGNofHA4
- Browse official “Go Docs” https://go.dev/doc/
- Learning Roadmap https://roadmap.sh/golang
- A TDD journey with the Coding Challenge #12 (my article on TDD with Golang)
Level 4 - intermediate stuff
- Book: “100 Go Mistakes and How to Avoid Them”, Teiva Harsanyi (you don’t need books to learn Go, but this book is The Book when - it comes to advancing to the next level in Go programming)
- YouTube: “7 common mistakes in Go and when to avoid them”, Steve Francia - https://youtu.be/29LLRKIL_TI YouTube: “Ashley McNamara + Brian Ketelsen. Go best practices”. https://youtu.be/MzTcsI6tn-0
- YouTube: “Package Oriented Design”, William Kennedy https://youtu.be/spKM5CyBwJA
- Practical Go blog https://dave.cheney.net/practical-go (all the stuff!, especially: “Practical Go: Real world advice for - writing maintainable Go programs” https://dave.cheney.net/practical-go/presentations/gophercon-israel.html and Constant Errors - https://dave.cheney.net/2016/04/07/constant-errors YouTube: “Practical Go Programming”, A. Gerrand https://youtu.be/2-pPAvqyluI Gophercises - Free course of advanced topics: https://gophercises.com/
- LinkedIn Learning “Level Up: Go” https://www.linkedin.com/learning/level-up-go
- Go 101 (in-depth explanations for many topics, first part of free) https://go101.org/article/101.html + Go Generics 101 https://- go101.org/generics/101.html + Go101 wiki https://github.com/go101/go101/wiki
- How to structure Go project https://go.dev/doc/modules/layout Zet Code Tutorials https://zetcode.com/all/#go
Level 5
- Some helpful resources:
- How to think in Go https://www.slideshare.net/lestrrat/how-to-think-in-go
- 6 years of Go https://peter.bourgon.org/go-best-practices-2016/
- Advanced concepts (chapters 39-4x): https://www.practical-go-lessons.com/
Level 6
- Awesome Go https://github.com/avelino/awesome-go
How to learn
Remember an old programming community wisdom - learning how to program or picking up a new language is best done by doing small projects - not by reading or doing tutorials alone. Think up a tool, a game or a service and code it in Go - looking up missing elements as you go (no pun intended).
I hope my guide - suggested first steps - will point you to materials worth digging into.
Call to action
Learn Go.
Andrzej Nowik/2024.04.02v1.2
.