报错提示:
build command-line-arguments: cannot load github.com/gomodule/redigo/redis: ambiguous import: found github.com/gomodule/redigo/redis in multiple modules:
github.com/gomodule/redigo v2.0.0+incompatible (/Users/why/Desktop/go/pkg/mod/github.com/gomodule/redigo@v2.0.0+incompatible/redis)
github.com/gomodule/redigo/redis v0.0.0-20200429221454-e14091dffc1b (/Users/why/Desktop/go/pkg/mod/github.com/gomodule/redigo/redis@v0.0.0-20200429221454-e14091dffc1b)
定位发现go.sum中有2个版本的redigo,原因是依赖的包中用的redigo和当前项目的redigo版本不同,造成了冲突,把其中一个redigo版本替换为另一个版本即可:
go.mod文件添加:
replace github.com/gomodule/redigo v2.0.0+incompatible => github.com/gomodule/redigo/redis v0.0.0-20200429221454-e14091dffc1b