go-for-c โ interactive
A fast-paced, example-based introduction to Go for people fluent in C. The code examples are live: edit any snippet and press Run to execute it in your browser.
Code runs on the public codapi.org sandbox (Go 1.27). Each example also shows its expected output, so the page is useful even offline. The exercises themselves live in the repository โ clone it and make the tests pass.
Modules
- 01Basics zero values, overflow, multiple returns, slices, append, conversions
- 02Strings & Runes strings as bytes, runes, UTF-8, strings.Builder
- 03Structs & Methods methods, value vs pointer receivers, embedding
- 04Interfaces implicit satisfaction, any, type switches
- 05Errors errors as values, %w wrapping, errors.Is/As
- 06Goroutines go, sync.WaitGroup, data races, sync.Mutex
- 07Channels channels, close/range, select, pipelines, fan-in
- 08Generics type parameters, any/comparable/cmp.Ordered constraints
- 09io.Reader & io.Writer io.Copy, bytes.Buffer, bufio.Scanner, TeeReader
- 10Maps & JSON maps, comma-ok, struct-tag JSON, omitempty
- 11defer, panic & recover defer LIFO, panic, recover into an error
- 12Capstone word-frequency report tying it together
- 13Testing table-driven subtests, t.Helper, benchmarks, fuzzing
- 14Modules & Tooling go.mod, semver, the go command, a runnable comparator
How to use these
Read top to bottom. When you hit a snippet, try changing a value and running it to check your understanding. The matching exercise directory in the repo has a stub to fill in and a test that defines "done".