Fixing go: inconsistent vendoring in C:\Go\src

Viewed 20096

I recently started learning Go programming language for Web and now I can't build my project. I'm getting "inconsistent vendoring". I checked github and the library is missing i.e. (Actually the library is still there but with no v0.1.0) vscode error type on build

4 Answers

Run the following before go build

go mod tidy
go mod vendor

This problem can also occur if you vendor/modules.txt file is missing. This happened in a project that gitignored *.txt and the solution was simply to commit this file and then follow what @amit-basuri wrote in his answer.

On windows:

Initially, I had my packages in C\:Go\src. It turns out that, go creates other directories in C:\Users\USERNAME\go\src\. I therefore moved my (personal) packages into the C:\Users\USERNAME\go\src\ folder and those from github into the C:\Users\USERNAME\go\src\github.com folder. Everything started working again.

I was having the same problem recently, all I had to do was remove the go.mod and go.sum files I created in my C:User\go\src directory.

I guess this happens because go.mod is meant to be used outside your working directory and since these files are located in the source directory, you don't need

Related