Let's Go: Learn Go in 30 days
05 Jul 2020 #letsX #goDo you want to learn a new programming language but don’t know what language to choose? Have you heard about Go? Well, let’s learn Go in 30 days!
From its official page, Go is “an open source programming language that makes it easy to build simple, reliable, and efficient software”.
Go is a popular language. According to Stack Overflow Developer Survey, since 2020, Go is in the top 10 of most admired/desired languages and in the top 15 of the most popular languages.
Docker, Kubernetes, and a growing list of projects use Go.
Why to choose Go?
Go reduces the complexity of writing concurrent software.
Go uses the concept of channels and goroutines. These two constructs allow us to have a “queue” and “two threads” to write to and read from it, out-of-the-box.
In other languages, we would need error-prone code to achieve similar results. Threads, locks, semaphores, etc, …
Rob Pike, one of the creators of Go, explains channels and goroutines in his talk Concurrency is not parallelism.
How to learn Go? Methodology
To learn a new programming language, library or framework, stop passively reading tutorials and copy-pasting code you find online.
Instead, follow these two principles:
1. Learn something by doing. This is one of the takeaways from the book Pragmatic Thinking and Learning. Instead of watching videos or skimming books, recreate examples and build mini-projects.
2. Don’t Copy and Paste. Instead of copy-pasting, read the sample code, “cover” it and reproduce it without looking at it. If you get stuck, search online instead of going back to the sample. For exercises, read the instructions and try to solve them by yourself. Then, check your solution.
“Instead of dissecting a frog, build one”.
― Andy Hunt, Pragmatic Thinking and Learning
Resources
Before starting to build something with Go, we can have a general overview of the language with the Pluralsight course Go Big Picture.
To grasp the main concepts, we can follow Learn Go with tests. It teaches Go using the concept of Test-Driven Development (TDD). Red, green, and refactor.
Other helpful resources to are Go by Example and Go documentation.
“To me, legacy code is simply code without tests.”
― Michael C. Feathers, Working Effectively with Legacy Code
Basic
- Guess the number, simple calculator
- Build some CLI tools like cowsay, lolcat, and fortune
- Build your own shell
- Caesar cipher
Intermediate
- Fun weekend projects like an Slack bot (a Twitter bot if you prefer Twitter) or a simple key-value store. You can find another take of a Slack bot here
- Write a data structure like a linked list, a stack, or a queue
- Build a CLI wrapper for XKCD
- Build and test a REST API with PostgreSQL or Build a REST API with Fiber and SQLite
- Build an API client
- The Super Tiny Compiler
- If you’re coming from Node.js API for Node.js developers
Advanced
- An HTTP Server in Go From scratch
- Write cleaner web servers
- Create an FTP Client. You need to understand sockets
- Write a SQL database
- Writing a document database from scratch in Go
- Let’s Create a Simple Load Balancer With Go
- Building a BitTorrent client from the ground up in Go
Fullstack
- Chat with Angular or React
- Url shortener with Redis or CouchDB. Another take with Redis and Iris
- Blog App Tutorial
- Building a Microservice
You can find more project ideas here: 40 project ideas for software engineers, What to code, Build your own x and Project-based learning.
Conferences
- Concurrency is not parallelism
- How do you structure your Go apps
- Things in Go I Never Use
- Best Practices for Industrial Programming
- 7 common mistakes in Go and when to avoid them
Conclusion
Go was designed to reduce the clutter and complexity of other languages. Go syntax is like C. Go is like C on asteroids. Goodbye, C pointers! Go doesn’t include common features in other languages like inheritance or exceptions. Yes, Go doesn’t have exceptions.
However, Go is batteries-included. You have a testing and benchmarking library, a formatter, and a race-condition detector. Coming from C#, you can still miss assertions like the ones from NUnit or XUnit.
Aren’t you curious about a language without exceptions? Happy Go time!
You can find my own 30-day journey following the resources from this post in LetsGo