Safeguard
Developer Tools•

What does // indirect mean in go.mod?

An indirect comment in go.mod marks a module your code does not import directly. It is still in your build, so it still needs vulnerability scanning.

Safeguard Security Team
3 min read

An indirect comment in go.mod marks a required module that no package in your main module imports directly. It is there because one of your dependencies needs it. It is still part of your build, so a vulnerability in it can still affect you and should be scanned like any other.

Definitions

go.mod. The file that defines your module and lists required modules with minimum versions.

go.sum. A file of checksums the go command uses to verify module downloads.

Indirect requirement. A module listed in go.mod solely because a dependency needs it.

Build list. The set of module versions the go command selects for a build.

What the Go reference says

The Go modules reference defines the comment directly: it means no package from that module is imported by any package in the main module. In Go 1.17 and higher, an indirect requirement is added for every module that provides any package imported, even indirectly, by a package or test in the main module. Those lines sit in a separate block.

For this reason, a modern go.mod gives you a fairly complete view of the modules in play. The command go list with the all pattern shows the full build list with selected versions.

go list -m all
go list -m -u all

The second form adds upgrade information and marks deprecated and retracted versions.

Why scanners care

File or commandWhat it tells a scanner
go.mod direct linesModules you chose
go.mod indirect linesModules pulled in by others
go.sumChecksums that confirm content, not a full inventory
go list -m allThe selected versions for the whole build

A vulnerability database such as the Go vulnerability database lists affected module paths and version ranges. Matching those ranges against the build list tells you what is exposed.

Steps to act on an indirect finding

  1. Run govulncheck from the module folder.
  2. Read the affected section first, where call stacks show your code reaching the flawed function.
  3. For informational findings, with no call stack, decide whether the risk is worth an upgrade now or later.
  4. Upgrade the module to the fixed version listed in the output.
  5. Run go mod tidy and re-scan.

The Go tutorial notes that upgrading to the highest fixed version in a module can clear several findings at once.

Quick check

Can I delete an indirect line to remove the dependency?

Not safely. The line reflects a real need. Run go mod tidy and let the tool maintain it.

Is an indirect module less risky?

Not by default. It runs in your binary if the vulnerable code is reached.

Safeguard reads Go module files for dependency scanning and reachability analysis. You can run a free scan.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.