Go "usage: require module/path v1.2.3" malformed go.mod require in CI
Every require line in go.mod must name a module path and a version. A line missing the version, or with extra tokens, is rejected with the usage hint for the require directive.
What this error means
A go command fails parsing go.mod with "go.mod:7: usage: require module/path v1.2.3" pointing at a malformed require line.
go.mod:7: usage: require module/path v1.2.3Common causes
A require line without a version
The module path was added by hand without the v version, so the directive is incomplete.
A merge artifact or stray token on the line
A bad merge left extra text on the require line, breaking the expected two-field form.
How to fix it
Let go mod tidy normalize go.mod
- Fix the obvious malformed line, then run
go mod tidyto canonicalize the file. - Commit the corrected go.mod and go.sum.
- Re-run the build.
go mod tidyWrite the require line by the rule
Each require is module/path version, optionally grouped in a require ( ... ) block.
require (
example.com/lib v1.4.2
)How to prevent it
- Edit dependencies with
go get/go mod tidy, not by hand. - Review go.mod diffs after merges for stray tokens.
- Keep require blocks in the canonical two-field form.