Proposals Unofficial Go proposal tracker

Add GoMod, Dir, and other module fields to analysis.Module

#73878 · x/tools/go/analysis · low impact · Accepted ·

The analysis.Module type, which analyzers see through Pass.Module, provides only Path and Version (plus GoVersion). Analyzers that need the module's files, such as a linter that reads go.mod and go.sum to check dependencies, have no way to find them.

The proposal adds all remaining fields from packages.Module to analysis.Module: Time, Dir, GoMod, etc. Drivers such as singlechecker, multichecker, unitchecker, go vet/go fix, and gopls fill in these fields.

func run(pass *analysis.Pass) (any, error) {
    if m := pass.Module; m != nil && m.GoMod != "" {
        sum := filepath.Join(filepath.Dir(m.GoMod), "go.sum")
        // read go.mod and go.sum ...
    }
    return nil, nil
}
Proposal
#73878 by AkihiroSuda
Status
Accepted on Mar 4, 2026
Impact
low
Area
x/tools/go/analysis