Skip to main content

End of the Go Course

Summary and Final Challenge

Congratulations! You have completed all 10 modules and 50 lessons of the Go course — from var and := fundamentals to slice backing arrays, goroutines, channels, select, context, table-driven tests, generics, and net/http services. Review the map below and tackle the 5-step final challenge.

10 modules · 50 lessons · 250 checkpoints

Go exercises are verified locally in the browser using Tree-sitter AST parsing (`tree-sitter-go.wasm`) plus structural and keyword checks; for live compilation with the official Go toolchain, click Open on Go Playground (go.dev/play).

01 · Basics of language

The foundation: packages, variables, types, constants, operators and input/output with the fmt package.

  • var / := / const
  • zero value
  • iota
  • fmt.Printf

02 · Flow Control

Decisions and repetitions: if with init statements, the unique `for`, idiomatic switch and explicit error handling.

  • if with init
  • for / for-range
  • switch
  • if err != nil

03 · Functions

Functions as first class citizens: signature, multiple returns, variadic parameters, closure and `defer`.

  • multiple returns
  • variadic ...T
  • closures
  • defer LIFO

04 · Collections

Array, slice (the most important structure), map, rune in strings and sorting.

  • arrays [N]T
  • slice len/cap
  • map comma-ok
  • utf8 / sort

05 · Structs and methods

Composite data types: struct, methods on receiver value or pointer, composition (no inheritance) and tag.

  • struct
  • value vs *T
  • embedding
  • json tags / NewT

06 · Interfaces

Structural interfaces (no explicit implementations), assertion, type switches and the standard `Stringer` and `error` interfaces.

  • implicit interfaces
  • type assertion
  • type switch
  • Stringer / error

07 · Competition

The concurrency model of Go: goroutine read, channel for communication, `select`, sync and context.

  • goroutines
  • buffered channel
  • select / default
  • Mutex / context

08 · Essential standard library

The packages you will use every day: fmt, strings, strconv, io, os, time, encoding/json.

  • fmt %+v
  • strings / strconv
  • io / os
  • time / json

09 · Testing, modules and tooling

The `go test` tool, table-driven testing, benchmarking, dependency management with `go mod` and build tags.

  • testing.T
  • table-driven t.Run
  • Benchmark
  • go.mod / //go:build

10 · Idiomatic practice

Naming, advanced error handling, generics (Go 1.18+) and two mini-projects: CLI and server HTTP.

  • naming / gofmt
  • %w / Is / As
  • Generics [T any]
  • CLI / net/http

The Final Challenge, in Five Steps

Put idiomatic Go into practice across five progressive stages: FilterEvens over slices, CountWords over maps, CountWordsHandler with net/http + encoding/json, MapSlice[T, U any] + %w error wrapping with errors.Is, and a bounded RunPool with goroutines and sync.WaitGroup.

1 · Filter Even Numbers into a Pre-allocated Slice

Implement FilterEvens(nums []int) []int using make([]int, 0, len(nums)) and for-range iteration (Module 4 + Module 2).

Exercise#go.boss.e1
Attempts: 0Loading…

Define func FilterEvens(nums []int) []int returning a new slice with only even integers from nums in original order, using for _, n := range nums, n%2 == 0, and append.

Loading editor…
Show hint

Initialize out := make([]int, 0, len(nums)) and inside for _, n := range nums check if n%2 == 0 { out = append(out, n) }.

Solution available after 3 attempts

2 · Count Word Frequencies with strings and map

Implement CountWords(text string) map[string]int using strings.Fields and an initialized map (Module 8 + Module 4).

Exercise#go.boss.e2
Attempts: 0Loading…

Define func CountWords(text string) map[string]int splitting text with strings.Fields, allocating out := make(map[string]int), and incrementing out[w]++ in a for-range loop.

Loading editor…
Show hint

Never write to a nil map: allocate out := make(map[string]int) first, then range over strings.Fields(text).

Solution available after 3 attempts

3 · JSON HTTP Handler with net/http

Build CountWordsHandler(w http.ResponseWriter, r *http.Request), setting Content-Type before encoding JSON (Module 10 + Module 8).

Exercise#go.boss.e3
Attempts: 0Loading…

Implement func CountWordsHandler(w http.ResponseWriter, r *http.Request) reading r.URL.Query().Get("q"), setting "Content-Type" to "application/json", and encoding CountWords(q) via json.NewEncoder(w).Encode.

Loading editor…
Show hint

Always invoke w.Header().Set("Content-Type", "application/json") BEFORE calling json.NewEncoder(w).Encode(CountWords(q)).

Solution available after 3 attempts

4 · Generics & Idiomatic %w Error Wrapping

Combine type parameter [T, U any] transformation with wrapped sentinel errors inspectable via errors.Is (Module 10 + Module 6).

Exercise#go.boss.e4
Attempts: 0Loading…

Define generic MapSlice[T, U any](items []T, fn func(T) U) []U using make([]U, len(items)), plus ParsePort(raw string) (int, error) wrapping ErrInvalidPort with fmt.Errorf("%w").

Loading editor…
Show hint

In MapSlice loop for i, v := range items { out[i] = fn(v) }; in ParsePort return 0, fmt.Errorf("parse port %q: %w", raw, ErrInvalidPort) on error.

Solution available after 3 attempts

5 · Concurrent Worker Pool with WaitGroup & Channels

Coordinate multiple goroutines reading typed jobs and closing the output channel safely after completion (Module 7).

Exercise#go.boss.e5
Attempts: 0Loading…

Complete RunPool(jobs []int, workers int) []int spawning workers goroutines synchronized with sync.WaitGroup that square each job from chJobs into chResults and close chResults once wg.Wait() returns.

Loading editor…
Show hint

Fill chJobs := make(chan int, len(jobs)) then close(chJobs); call wg.Add(1) + go func() { defer wg.Done() ... }() and close(chResults) in a waiter goroutine after wg.Wait().

Solution available after 3 attempts

Printable Go Cheatsheet (13 sections)

Complete quick reference covering Go types, zero values, slices, maps, interfaces, goroutines, stdlib, testing, and generics.

Open cheatsheet

What’s next?

The fastest way to solidify Go is hands-on building: open the Go Playground or run `go mod init` locally to combine CLI flags, worker concurrency, and an HTTP endpoint into a complete service.