'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/[email protected]: 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
gopkg.in/redis.v5
gopkg.in/redis.v5/internal
gopkg.in/redis.v5/internal/consistenthash
gopkg.in/redis.v5/internal/hashtag
gopkg.in/redis.v5/internal/pool
gopkg.in/redis.v5/internal/proto

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.



Solution 1:[1]

Just to add to @rustyx's answer, in order to fix this error, I deleted the vendor folder and then I ran again go mod vendor, and the error disappeared.

Solution 2:[2]

For me updating the version solved the issue. I was running go1.16 and I updated to go1.18.2. Before the update I tried go mod vendor and also updating the modules.txt didn't work then, I started ignoring the vendor directory by running go build -mod=mod to build the application or go run -mod=mod main.go to run the main.go file

Solution 3:[3]

You need to inject an instance of the NavigationManager

@inject NavigationManager navigationManager

Then you can use it

navigationManager.NavigateTo("...")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Lethabo Moses Monama
Solution 3 Mister Magoo