Learn to structure Go code into reusable pieces — functions with multiple returns, closures, variadics and defer, then packages and modules that organise and version your code. You will finish able to split a program into clean, importable packages and manage its dependencies with go modules.
Watch the free preview
Functions, parameters and multiple return values — free to watch, no account needed.
What you'll learn
- Structure Go code into reusable pieces using functions, packages and modules
- Write functions with multiple return values, closures and variadic parameters
- Use defer to guarantee cleanup runs even when a function returns early
- Create packages with exported and unexported identifiers and document them idiomatically
- Initialise a go module, add a versioned dependency and tidy the module graph
Syllabus
Functions — the Core Building Block
Functions, parameters and multiple return valuesFree preview
Function values and closures
Flexible Functions — Variadics and defer
Variadic functions
defer, and guaranteed cleanup
Packages — Organising Code
Creating packages, exported vs unexported
Documentation conventions and go doc
Modules — Versioning and Dependencies
Go modules and versioning
Adding and tidying dependencies
Lab — 10 Exercises & Solutions
Exercises 1–5
Exercises 6–10