What does "inconsistent vendoring" mean in Go?


I’m getting this inconsistent vendoring error and I’m a total Go newbie. Can anyone explain to me how go.mod interacts with vendor/modules.txt? I found this question helpful, and now I’m wondering if I should even have a vendor directory. Would that be created by running go mod vendor? I inherited this project and it already has the vendor directory in git.

Here’s the relevant part of my go.mod file –

module mymodule

go 1.17

require (
        gopkg.in/redis.v5 v5.2.9

And then the related error message:

go: inconsistent vendoring
gopkg.in/redis.v5@v5.2.9: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt

In vendor/modules.txt I have:

#gopkg.in/redis.v5 v5.2.9

For what it’s worth I’m getting this error for every dependency in my go.mod file, I just included the one about redis.


go.mod and vendor/modules.txt (if present) must be in sync.

Whenever go.mod changes and there is a vendor directory, go mod vendor needs to be run to update the contents of the vendor directory.

All direct dependencies (not marked // implicit in go.mod) are "explicit" and marked accordingly in vendor/modules.txt starting from Go 1.14.

After running go mod vendor notice the new line ## explicit added after the package reference:

#gopkg.in/redis.v5 v5.2.9
## explicit
. . .

Answered By – rustyx

Answer Checked By – Marilyn (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.