如何修复”go: inconsistent vendoring”错误?

huangapple go评论130阅读模式
英文:

How do I fix "go: inconsistent vendoring"?

问题

我正在进行一个使用Golang的项目。在一个功能分支上,我使用了一个创建供应商文件夹的框架。我切换回主分支后,当我运行:

go run main.go

我得到了以下错误信息:

go: inconsistent vendoring in /path/to/my/project:
	github.com/foo/bar@v0.9.3: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt

我尝试运行go mod tidy,但它没有解决这个问题。

我还尝试检出先前版本的go.mod和go.sum,但没有成功。

英文:

I'm working on a golang project. In a feature branch I'm using a framework that creates a vendor folder. I switched back to the main branch and now when I run:

go run main.go

I get

go: inconsistent vendoring in /path/to/my/project:
	github.com/foo/bar@v0.9.3: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt

I've tried running go mod tidy but it doesn't resolve the issue.

I also tried checking out a previous version of go.mod and go.sum with no luck.

答案1

得分: 1

我正在处理一个功能分支,该分支在项目目录中创建了一个vendor/目录。在.gitignore文件中,我们忽略了vendor目录,所以当我切换回其他分支时,该文件夹仍然存在。如果该目录可用,Go将始终查找并使用它。

要解决这个问题,我只需要删除/重命名vendor目录。

英文:

I was working on a feature branch that was creating a vendor/ directory inside the project directory. In .gitignore we are ignoring the vendor directory so when I moved back to the other branch it was leaving that folder there. Go will always look for and use that directory if it's available.

To fix the issue I just needed to remove/rename the vendor directory.

huangapple
  • 本文由 发表于 2023年6月2日 02:10:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76384608.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定