Skip to Content
Skip to content
Tutorials

Programming Tutorials

Standalone programming tutorials for solving one specific problem at a time. Each guide starts with the exact error message, failing behavior, or design constraint, gives you a minimal reproducible script or query, and walks through the fix with real output.

Pick a language below or filter by topic and difficulty when you need a quick, practical reference you can test locally and apply right away.

Go
Embed Static Files and Build Versions Into a Go Binary Level: Advanced

Bundle static files with //go:embed and embed.FS, serve subdirectories cleanly with fs.Sub, and inject version strings with -ldflags -X or debug.ReadBuildInfo.

Go
Why a Typed Nil Pointer Is Not == nil in Go Interfaces Level: Intermediate

Reproduce Go's typed-nil interface trap with custom errors and io.Writer, see why w == nil returns false, and fix return paths cleanly.

Go
Add Context Deadlines to Outbound HTTP Calls in Go Level: Intermediate

Replace http.Get with http.NewRequestWithContext, combine Client.Timeout with per-call context.WithTimeout, and detect DeadlineExceeded cleanly.

Go
Replace fmt.Println With Structured JSON Logging in Go (log/slog) Level: Intermediate

Switch from fmt.Println to log/slog JSON logs, attach request-scoped attributes with With, redact secrets using LogValuer, and change log levels at runtime.

Go
Install Go, Check Your Path, and Initialize a Module Level: Beginner

Verify your Go installation with go version and go env, initialize a module with go mod init, and fix go.mod not found errors.

Go
Strings, Bytes, and Runes in Go: Why len() Counts Bytes Level: Beginner

See why len() counts UTF-8 bytes instead of characters, iterate safely over runes with range, and slice UTF-8 text without splitting multi-byte characters.

Go
Value vs. Pointer Receivers in Go: Why Method Changes Disappear Level: Beginner

Reproduce lost struct mutations with value receivers, switch to pointer receivers cleanly, and keep receiver types consistent across a struct.

Go
Wrap and Check Errors in Go With fmt.Errorf("%w") and errors.Is Level: Beginner

Add context to Go errors using fmt.Errorf("%w"), inspect wrapped chains with errors.Is and errors.As, and avoid breaking checks with == or %v.

Go
Write Table-Driven Unit Tests in Go With testing.T and t.Run Level: Beginner

Structure Go unit tests as a slice of cases, run named subtests with t.Run, and choose between t.Fatalf and t.Errorf.

Go
Stream Large Files and HTTP Bodies With bufio.Scanner and io.LimitReader Level: Intermediate

Read large text streams line by line with bufio.Scanner, copy streams in bounded memory with io.Copy, and cap untrusted HTTP bodies with io.LimitReader.

Go
Cancel Slow Work With context.WithTimeout and r.Context() Level: Intermediate

Propagate cancellation signals and deadlines with context.WithTimeout, pair every context with defer cancel(), and respect r.Context() in HTTP handlers.

Go
Set ReadHeaderTimeout and Keep-Alive Timeouts on http.Server Level: Intermediate

Replace http.ListenAndServe with an explicit http.Server configured with ReadHeaderTimeout, ReadTimeout, WriteTimeout, and IdleTimeout.