Skip to main content
Module 9 · Lesson 4 of 544/50 in the course~12 min
Module lessons (4/5)

Go modules

Lesson preview5 hands-on exercises readyCourse Go · Module 9 — Testing, modules and tooling

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, and require directives in go.mod and the role of go.sum.
  • Sync imports and dependencies with go mod tidy and go 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 with go.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

  1. 1The go.mod manifest and the go.sum lockfile
  2. 2Import of sub-packages and blocking import (...)
  3. 3Semantic Import Versioning (v2+)
  4. 4Multi-Module Workspace (go work)
  5. 5Guided practice
  6. 6Check for understanding
Pro Lesson · Module 9 — Testing, modules and tooling

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.