module declares its path as: github.com/xxx/yyy【Go报错】

一、报错

github.com/aaa/yyy: github.com/aaa/yyy@v1.14.6: parsing go.mod:
module declares its path as: github.com/xxx/yyy
but was required as: github.com/aaa/yyy

二、解决

由于aaa是fork别人xxx的yyy项目,所以这个时候直接使用会报错,需要在自己的项目下提交一个tag在go mod中替换就可以。

require github.com/xxx/yyy v1.10.0 // 获取原本的项目
replace github.com/xxx/yyy v1.10.0 => github.com/aaa/yyy v0.0.0 //替换aaa的项目

三、引用

现在就可以使用aaa下的yyy项目的代码,但是在使用的时候还是引入xxx的项目,如下

import "github.com/xxx/yyy" 
原文地址:https://www.cnblogs.com/zrl66/p/14349304.html