Skip to content

Table of Contents

Go Cheat Sheets

A dense, copy-pasteable reference for learning and remembering Go. Every file is self-contained with runnable go snippets.

Index

Cheat sheet What's inside
syntax-basics.md Variables, constants, iota, types, zero values, control flow, functions, multiple/named returns, defer.
slices-maps-arrays.md Slice internals (len/cap/backing array), append/copy, delete/insert/filter tricks, map idioms, ordered iteration, gotchas.
strings-runes-bytes.md string vs []byte vs []rune, UTF-8, strings/strconv/bytes, strings.Builder, fmt verbs.
structs-interfaces-generics.md Struct tags, embedding, method sets, interface satisfaction, type switches/assertions, generics & constraints.
errors.md Wrapping with %w, errors.Is/As/Join, sentinel & custom errors, panic/recover, idiomatic patterns.
concurrency.md Goroutines, channels, select, sync primitives, atomic, context, worker pools, fan-in/out, errgroup.
testing.md Table-driven tests, subtests, t.Parallel, testify, benchmarks, fuzzing, examples, coverage, httptest, mocks.
stdlib-essentials.md net/http, encoding/json, database/sql, io/bufio, time, context, log/slog, flag, os/exec.
tooling-and-modules.md go mod, build/test/vet, build tags, cross-compile, test flags, pprof, golangci-lint, Makefile.
go-commands.md Quick-reference table of every common go subcommand and flag.

Conventions used here

  • // => marks the printed/returned result of an expression.
  • Snippets assume import lines are added; obvious imports are sometimes elided for brevity.
  • Tested against Go 1.22+ (loop variable per-iteration scoping, for range int, etc.).