Skip to content
Learn Netverks

Lesson

Step 26/36 72% through track

go-modules

Go modules

Last reviewed May 28, 2026 Content v20260528
Track mode
server_compiled
Means
Compiled runner
Reading
~1 min
Level
intermediate

This lesson

This lesson teaches Go modules: the syntax, patterns, and safety habits you need before advancing in Go.

go mod tidy and semantic import versioning matter for reproducible builds and security reviews.

You will apply Go modules in contexts like: Kubernetes ecosystem tools, cloud APIs, and CLI utilities.

Write Go in main.go with package main and func main(), click Run on server—the dev runner runs go run main.go; use fmt.Println for output (requires Go toolchain; LEARNING_RUNNER_ENABLED=true).

When you can explain the previous lesson's ideas without copying starter code.

Modules are Go's dependency system: go mod init example.com/app creates go.mod. Versions are semantic; go.sum records checksums for reproducible builds.

Common commands

  • go get module@v1.2.3 — add or upgrade dependency
  • go mod tidy — add missing, remove unused modules
  • go mod vendor — copy deps into vendor/ for air-gapped builds

Minimum version selection

Go resolves the minimum compatible versions satisfying all requirements—understand upgrades before bumping major versions in production.

Important interview questions and answers

  1. Q: go.mod vs go.sum?
    A: go.mod declares module path and requirements; go.sum verifies content hashes.
  2. Q: GOPATH still required?
    A: Modules are default—GOPATH mainly legacy or global tool installs.

Self-check

  1. Which file lists module dependencies?
  2. What does go mod tidy do?

Pitfall: Commit both go.mod and go.sum—missing sums break reproducible CI builds.

Interview prep

go.mod vs go.sum?

go.mod declares module; go.sum verifies dependency content hashes.

go mod tidy?

Adds missing module requirements and removes unused ones.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • go.sum purpose?
  • replace directive?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump