Skip to content
Latchkey

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
go.mod:7: usage: require module/path v1.2.3

Common 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

  1. Fix the obvious malformed line, then run go mod tidy to canonicalize the file.
  2. Commit the corrected go.mod and go.sum.
  3. Re-run the build.
Terminal
go mod tidy

Write the require line by the rule

Each require is module/path version, optionally grouped in a require ( ... ) block.

go.mod
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.

Frequently asked questions

What causes ""usage: require module/path v1.2.3""?
The module path was added by hand without the v version, so the directive is incomplete.
How do I fix "usage: require module/path v1.2.3"?
Let go mod tidy normalize go.mod

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card