Description
background
An analysis framework was built out for the go language, to make writing linters (and metalinters easier). go.mod
files are another custom dsl, where you may want to enforce standards. Thus it seems reasonable to make an analysis package for modules.
One of the big potential benefits is an official "get me the main go.mod
" function, since currently guessing or slurping go env -json
are the best bad options. Furthermore, third party go.mod
linters have already started popping up: gomodguard.
alternatives
The exact location is not terribly important, it could also be golang.org/x/tools/go/analysis/modanalysis
or golang.org/x/mod/analysis
, but golang.org/x/tools/go/analysis/modanalysis
seems reasonable.
Instead of adding a whole new package and interface, it may be easier to add a ModPass
struct based on the go.mod
syntax, a new ModRun func(*ModRun) (interface{}, error)
struct field, and the plumbing to read in the main go.mod
. This seems like a choice for someone more familiar with the current package.