1. Meet Go and write your first program
BeginnerUnderstand Go's design, toolchain, program structure, and basic console output.
Packages, imports, and main
A Go executable starts in package main at the main function.
Run, build, and format Go code
The go tool runs, builds, formats, and tests Go projects.
Comments, names, and basic syntax
Go uses case-sensitive identifiers and familiar line and block comments.
Module checkpoint: Create main.go that prints your name, the Go version you are learning, and three short lines of output. Format it with gofmt and run it with go run.
2. Variables, types, and constants
BeginnerDeclare values, select suitable types, and understand initialization, constants, and conversions.
Variables and short declarations
Variables have declared types, and := infers a local variable's type.
Built-in types and zero values
Go provides numeric, Boolean, string, and byte/rune types for common data.
Constants and type conversions
Constants name fixed values, and Go requires explicit conversions between many distinct types.
Module checkpoint: Write a small receipt calculation that uses a constant tax rate, an integer item count, a floating-point price, and an explicit conversion where needed.
3. Operators, decisions, and control flow
BeginnerEvaluate expressions, make decisions, and repeat work with Go's control-flow statements.
Arithmetic and comparison operators
Operators combine values into calculations and Boolean comparisons.
Conditions with if and else
Go conditions use if and may include an initializer before the condition.
Switch statements and for loops
Go uses switch for multiway branching and for as its looping construct.
Module checkpoint: Build a small grade classifier using if/else and switch. Then print numbers in a range using for and identify the condition that stops the loop.
4. Arrays, slices, and iteration
BeginnerStore ordered values and understand the crucial differences between arrays and slices.
Fixed-size arrays
An array has a fixed length that is part of its type.
Slices, make, and append
A slice describes a variable-length view over an underlying array.
Iterate with range and understand copying
range visits elements in arrays, slices, maps, strings, and channels.
Module checkpoint: Write a function that accepts a slice of integers and returns the minimum and maximum. Test empty, one-element, and multi-element slices, and document how an empty slice is handled.
5. Functions, multiple returns, and errors
BeginnerDesign reusable functions, pass values deliberately, and handle failures through Go's error convention.
Parameters and return values
Functions make behavior reusable and define clear inputs and outputs.
Multiple returns and early exits
Multiple return values can make success and failure paths explicit.
Create and handle errors
Go usually represents expected failures with explicit error return values.
Module checkpoint: Write a function that calculates an average and returns an error for an empty input. Write callers that handle both valid results and failures.
6. Maps, structs, and methods
IntermediateModel domain data with structs, look up values with maps, and attach behavior through methods.
Maps and safe lookups
Maps associate keys with values and report whether a key exists.
Structs and composite literals
Structs group named fields into an application-specific data type.
Methods and receivers
Methods associate behavior with a defined type through a receiver parameter.
Module checkpoint: Create a Task struct, use a map to look up tasks by ID, and add methods to mark a task complete. Handle lookups for IDs that do not exist.
7. Pointers, interfaces, and composition
IntermediateUnderstand addresses, express behavior with interfaces, and combine types without class inheritance.
Pointers and addresses
A pointer stores the address of a value, and the zero value of a pointer is nil.
Interfaces and implicit implementation
A type implements an interface by providing its required methods.
Composition and embedding
Go encourages composing types from smaller values and behaviors rather than class inheritance.
Module checkpoint: Define a small storage interface, implement it with an in-memory map-backed type, and write a function that accepts only the interface it needs.
8. Packages, modules, and developer tooling
IntermediateOrganize code into packages and modules and use the Go toolchain for repeatable development.
Go modules and dependencies
A module defines a project and records its dependency requirements.
Packages and exported APIs
Packages group related code, and capitalization controls which names are exported.
Formatting, vetting, and testing commands
Standard tools catch style problems, suspicious constructs, and regressions.
Module checkpoint: Create a module with a reusable package and a main package. Export one function, keep a helper unexported, then run gofmt, go test ./..., and go vet ./....
9. Strings, JSON, and file handling
IntermediateTransform text safely, encode structured data, and perform file operations with explicit error handling.
Strings, bytes, and Unicode
Go strings store bytes, so byte indexing and Unicode code-point iteration differ.
Encode and decode JSON
The encoding/json package converts between JSON data and Go values.
Read and write files
File operations return errors that must be handled and resources that must be closed.
Module checkpoint: Create a Task struct, encode a few tasks as JSON, save them to a file, load them back, and handle both filesystem and JSON decoding errors.
10. Generics, testing, and reusable code
IntermediateWrite generic helpers where useful and protect program behavior with automated tests and benchmarks.
Type parameters and constraints
Generics let functions and types operate on multiple types that meet a constraint.
Unit tests and table-driven tests
Go tests are functions named TestXxx in files ending with _test.go.
Benchmarks, coverage, and fuzzing
Different test tools investigate performance, execution coverage, and unexpected inputs.
Module checkpoint: Write table-driven tests for a slice-processing function. Run go test ./..., inspect coverage, and add a benchmark only for a performance question you actually need to answer.
11. Goroutines, channels, and synchronization
AdvancedRun concurrent tasks safely and coordinate them using channels, mutexes, and cancellation-aware patterns.
Goroutines and concurrent work
A goroutine is a lightweight unit of concurrent execution managed by the Go runtime.
Channels and select
Channels communicate values between goroutines and can coordinate work.
Wait groups, mutexes, and race detection
Synchronization tools coordinate completion and protect shared state.
Module checkpoint: Launch several workers, gather their results, and then modify a shared counter under a mutex. Run the race detector and explain how the code avoids deadlock and goroutine leaks.
12. Context, HTTP, and API clients
AdvancedBuild reliable networked code with HTTP handlers, request contexts, timeouts, and explicit response handling.
Context, deadlines, and cancellation
Context carries cancellation signals, deadlines, and request-scoped values across API boundaries.
HTTP clients and response handling
The net/http package provides HTTP clients and servers with explicit response and error handling.
HTTP handlers and JSON APIs
Handlers map HTTP requests to validated application behavior and responses.
Module checkpoint: Build a small HTTP health endpoint and a JSON endpoint. Add request validation, explicit status codes, timeouts on client calls, and tests for invalid methods and malformed input.
13. Performance, diagnostics, and release readiness
AdvancedUse profiles and diagnostics to find real bottlenecks, structure applications for testing, and prepare dependable builds.
Measure and profile performance
Benchmarks and profiles help identify the operations that consume time or memory.
Logging, tracing, and diagnostics
Useful diagnostics preserve enough context to explain failures without exposing secrets.
Application structure and release builds
Clear boundaries, repeatable checks, and explicit configuration make Go programs easier to maintain and ship.
Module checkpoint: Review the capstone for clear package boundaries, checked errors, useful logs, repeatable tests, and documented build steps. Run the full test and vet commands before building the release executable.