Skip to main content
Programming Languages

Go Tutorial with Examples.

Go tutorial with runnable examples: cloud-native Go for distributed systems, Kubernetes tooling, DevOps automation and high-concurrency backend services.

Beginner

Start here — no prior experience needed

12 lessons
go beginner
5 min read

What Go is and why it is used for cloud tools and CLIs, with a first program, a goroutine and a single static binary, each run with its real output.

go beginner
5 min read

Install Go and start a real module: go mod init, go run with arguments, go get, gofmt and go vet, and cross-compiling, each with its actual output.

go beginner
5 min read

Go variables run for real: var vs :=, zero values, the unused-variable compile error, multiple assignment and swaps, iota constants, and := shadowing.

go beginner
5 min read

Go's basic types run for real: integer overflow, float precision and NaN, strings vs bytes vs runes, explicit conversions, strconv, and defined types.

go beginner
5 min read

Go operators run for real: integer division and modulo signs, ++ as a statement, short-circuit logic, bit flags with &^, and why there is no ternary.

go beginner
5 min read

Go control flow run for real: if with an init statement, switch without fallthrough, the single for loop, range, and labelled break and continue.

go beginner
5 min read

Go functions run for real: multiple and named returns, variadic calls, closures and the loop-variable change, defer order and arguments, and init.

go beginner
5 min read

Go strings run for real: immutability, the strings package, Sprintf verbs, Builder vs += allocations, reversing by rune, Replacer, and regexp.

go beginner
5 min read

Go arrays and slices run for real: value vs view semantics, len and cap growth, append aliasing bugs, copy, deleting, 2D slices, and the slices package.

go beginner
5 min read

Go maps run for real: comma-ok lookups, the nil-map panic, random iteration order, struct values you can't assign, sets, and a concurrent-write crash.

go beginner
5 min read

Go structs run for real: literals and zero values, value vs pointer receivers, constructors, embedding and promotion, JSON tags, comparison, and padding.

go beginner
5 min read

Go packages and modules run for real: a multi-package module, exported names, the internal/ rule, replace and go.work, import cycles, and go doc output.

Intermediate

For developers with core concepts down

9 lessons
go intermediate
5 min read

Go interfaces run for real: implicit satisfaction, pointer-receiver method sets, type assertions and switches, Stringer, io.Reader, and the nil trap.

go intermediate
5 min read

Go errors run for real: errors as values, wrapping with %w vs %v, errors.Is and errors.As through a chain, custom types, errors.Join, and panic vs recover.

go intermediate
5 min read

Goroutines run for real: main exiting early, sync.WaitGroup, collecting results in order, a data race caught by -race, a goroutine panic, and GOMAXPROCS.

go intermediate
5 min read

Go channels run for real: unbuffered handoff, deadlocks, buffers, close and range, directional types, select with default and timeouts, and nil channels.

go intermediate
5 min read

Go concurrency patterns run for real: worker pools, bounded fan-out pipelines, context timeouts and cancellation, RWMutex, sync.Once, and errgroup limits.

go intermediate
5 min read

Go file I/O run for real: os.ReadFile and WriteFile, bufio.Scanner and its 64 KB line limit, a missing Flush, appending, walking directories, and JSON.

go intermediate
5 min read

Go testing run for real: a failing test, table-driven subtests, t.Error vs t.Fatal, httptest, examples, fuzzing that finds a bug, benchmarks, and coverage.

go intermediate
5 min read

A Go HTTP server run for real with curl: ServeMux patterns and the catch-all /, method routing, a JSON API, middleware, request context, graceful shutdown.

go intermediate
5 min read

Go command-line tools run for real: the flag package and -h, stdin pipes, stdout vs stderr, exit codes and os.Exit, env vars, subcommands, and cobra.

Advanced

Production-grade patterns for experienced engineers

4 lessons

Also part of Go

Taught in other topics. Each link opens the lesson in its home topic.

2 lessons