Chapter 48: Go Exercises
Go Exercises” — which is actually a very smart question at this stage.
When people (especially beginners) search or ask “Go Exercises”, they usually mean one of two things:
- The official interactive exercises that come with A Tour of Go → the most famous and most recommended starting point for 95% of learners
- General practice exercises / coding problems for learning Go → small tasks, katas, LeetCode-style problems, project ideas, etc.
Since you’ve already gone through many individual topics (variables, slices, maps, functions, structs, loops, etc.), I think you’re ready for both:
- Understanding what A Tour of Go exercises actually are
- Seeing a curated list of realistic, well-graded exercises you can do right now at your level
I’ll explain both in detail like your personal teacher — with examples you can immediately try in the browser or locally.
1. The Most Famous “Go Exercises” = A Tour of Go
Link: https://go.dev/tour/welcome/1 (You can run every example directly in the browser — no installation needed at first)
What it really is:
- An official, interactive tutorial made by the Go team
- ~70–80 small slides / pages
- Every page has:
- short explanation
- editable code box
- Run button
- often a small exercise / task at the end
- You must fix the code or complete the task to move forward on many pages
Main sections & typical exercises inside:
| Section | What you practice | Typical exercise example | Approx time |
|---|---|---|---|
| Basics | variables, functions, for, if, switch | “Implement a function that returns sqrt using Newton’s method” | 30–50 min |
| Flow control | for, if/else, switch, defer | “Make a loop that prints the first 10 Fibonacci numbers” | 20–30 min |
| More types | pointers, structs, arrays, slices, maps | “Implement Pic function that generates a 256×256 image” (2D slice) | 30–50 min |
| Methods & Interfaces | receiver functions, interface satisfaction | “Make a Stringer interface implementation for IPAddr type” | 30–50 min |
| Generics (since 1.18) | type parameters | “Write a generic function that reverses any slice” | 15–25 min |
| Concurrency | goroutines, channels, select | “Implement concurrent web crawler using channels” (hardest exercise in the tour) | 40–90 min |
Real example from the tour (one of the most famous exercises):
Exercise: Maps
Implement WordCount — it should return a map of word counts from a string.
|
0 1 2 3 4 5 6 7 8 9 |
func WordCount(s string) map[string]int { // Your code here return map[string]int{} } |
Solution skeleton (try to write it yourself first!):
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import "strings" func WordCount(s string) map[string]int { words := strings.Fields(s) count := make(map[string]int) for _, word := range words { count[word]++ } return count } |
How to do the tour exercises right now:
- Open https://go.dev/tour
- Go to More types → Exercise: Maps (or any other)
- Edit the code in the left pane
- Press Run or Format
- When it passes → press Next
Most people finish the whole tour in 3–8 hours depending on how much they experiment.
2. Beyond the Tour — Realistic Go Exercises for Your Level
Since you already know slices, maps, functions, structs, loops — here is a curated list of small-to-medium exercises you can do right now (sorted by difficulty).
Level 1 – Very quick warm-up (5–15 min each)
- Write function reverseSlice(s []int) []int that returns reversed copy
- Write function countWords(text string) map[string]int (like WordCount above)
- Write function filterEven(numbers []int) []int — returns only even numbers
- Write function maxValue(m map[string]int) (string, int) — returns key & value with highest number
Level 2 – Medium (20–40 min each)
- Todo list CLI
- struct Task { ID int, Title string, Done bool }
- slice []Task
- functions: AddTask, MarkDone, ListTasks, DeleteTask
- Word frequency analyzer
- Read string
- Count words (ignore case, punctuation)
- Print top 10 most frequent words
- Simple phone book
- map[string]string — name → phone
- functions: AddContact, GetPhone, DeleteContact, ListAll
Level 3 – Good mini-projects (1–3 hours)
- Recursive directory lister (prints folder tree like tree command)
- HTTP status code grouper — map[int]string — group codes by category (2xx, 4xx, 5xx)
- Anagram checker — two strings → are they anagrams? (use map or sort)
Where to find more graded exercises (2026 recommendations)
- https://go.dev/tour — start here if you haven’t finished
- https://gobyexample.com — short focused examples + exercises
- https://exercism.org/tracks/go — free, mentored Go track (very high quality)
- https://adventofcode.com — many people solve 2024/2025 problems in Go
- https://leetcode.com/tag/go/ — filter by Go tag
Your Next Step Right Now (My Personal Recommendation)
- Open https://go.dev/tour/moretypes/23 (Exercise: Maps)
- Try to solve it without looking at hints
- If stuck → ask me, I’ll guide you line by line
Or pick one from the level 1 list above and write it now — paste your code here if you want feedback.
Which kind of exercise sounds most interesting to you right now?
- Quick map/string practice
- Small CLI todo app
- Something recursive
- Something with structs + slices
Just tell me — I’ll give you a detailed guided exercise you can do immediately.
You’re doing really well — now is the perfect time to start writing & running your own small programs instead of only reading.
Keep going — I’m here whenever you want! 💪🇮🇳🚀
