GoMod环境问题 declares ... but was required as ...

595 阅读1分钟

使用 go mod tidy 进行依赖安装时 出现

如何解决 go mod tidy 出现的错误

如何解决 go mod tidy 出现的错误

go: code.byted.org/caijing_omega/common@v1.0.15 requires

        code.byted.org/caijing_omega/omega_fx_data@v0.0.0-20220217100028-c7df2fdcf8cb requires

        github.com/srlemon/gen-id@v1.0.1: parsing go.mod:

        module declares its path as: github.com/olongfen/gen-id

                but was required as: github.com/srlemon/gen-id

declares ...B... but was requiered as ...A... 项目中声明使用的是 B 但是在mod中被解释为A 此时使用 replace 进行修复

在 go.mod 文件中 加入 replace A vx.x.x => B vx.x.x 将编译的依赖解释结果中的A替换回B

image.png