go - 运行 go build 时出错。带有日志存储库

标签 go go-modules

我有一个带有 gomod 的 Go 程序,当我运行 go build 时。 我收到以下错误:

go: github.com/sirupsen/[email protected] used for two different module paths (github.com/Sirupsen/logrus and github.com/sirupsen/logrus)

我的 go mod 看起来像

require (

github.com/Sirupsen/logrus v1.4.2 // indirect
github.com/sirupsen/logrus v1.4.2

…

) 

我添加了以下内容,但没有帮助,知道吗?

replace (
   github.com/Sirupsen/logrus v1.4.2 => github.com/sirupsen/logrus v1.4.2
)

在我的项目代码中,我使用仅小写的import路径github.com/sirupsen/logrus

最佳答案

尝试删除//indirect行,然后运行

go mod tidy # prune any extraneous requirements + other stuff
go clean # remove object files and cached files
go get -v -u all # update everything related to the dependencies
go build # finger crossed!

关于go - 运行 go build 时出错。带有日志存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58500310/

相关文章:

go - 如何确定golang中连接的确切字节长度?

go - 如何解决 Go 项目中嵌套应用程序二进制文件中的依赖项?

go - 无法通过 SSH 安装 go 模块(私有(private)嵌套存储库)

go - 如何以新的方式构建 Golang 模块和项目结构

go modules - 替换不起作用 - 没有版本的替换模块必须是目录路径(根目录或以

go - 不允许分配相同的类型

go - Go中调用kernel32的ReadProcessMemory

go - 如何使用 golang 上下文功能而不是 golang http 客户端发出 http 请求?

不允许 Golang 导入循环

Go模块和依赖修改 vendor