Module lessons (4/5)
Go modules
go mod init, go get, semantic import versioning, lockfile go.sum, go mod tidy.
What you'll learn in this lesson
- Interpret the
module,go, andrequiredirectives ingo.modand the role ofgo.sum. - Sync imports and dependencies with
go mod tidyandgo get. - Apply Semantic Import Versioning by importing major release
v2+via suffix in the path. - Secure the internal API using
internal/packages and bundle modules in local development withgo.work.
Overview
Since 2018 (Go 1.11+) each project lives inside a module defined by go.mod and cryptographically verified by go.sum. Understanding how import paths, internal/ packages, and major versions resolve allows you to organize large codebases without dependency conflicts.
When the module is called example.com/myapp and contains a subfolder utils/, you always import it with the full path of the module regardless of where the directory is located on disk. Multiple imports are grouped into a single parenthesized block automatically sorted by gofmt:
Sections covered in this lesson
- 1The
go.modmanifest and thego.sumlockfile - 2Import of sub-packages and blocking
import (...) - 3Semantic Import Versioning (
v2+) - 4Multi-Module Workspace (
go work) - 5Guided practice
- 6Check for understanding
Unlock "Go modules" and the full Course Go curriculum
`go mod init`, `go get`, semantic import versioning, lockfile `go.sum`, `go mod tidy`.
Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in Course Go plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.