Show why a package or module is needed.

Section: Modules Basics

Explain dependency

bash
bash
go mod why -m github.com/pkg/errors
Explanation

Show why a package or module is needed. Useful in Go CLI workflows.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Modules Basics
Initialize module
Create a new go.mod for the current project.
OpenIn sheetbashsame section
Tidy dependencies
Add missing and remove unused module requirements.
OpenIn sheetbashsame section
Download dependencies
Pre-fetch required modules into the module cache.
OpenIn sheetbashsame section
Print module graph
Show the module dependency graph.
OpenIn sheetbashsame section
Add replace directive
Point a module dependency to a local checkout.
OpenIn sheetbash2 tag match
Add require directive
Add an explicit module requirement.
OpenIn sheetbash2 tag match