在项目中的go.mod文件中有这样一句:
require (
github.com/xxx-devops/xx1/sdk/go v2.2.3
)
项目的编译没有问题,但是goland中出现如下提示:
go: errors parsing go.mod:
D:/source/github/ahfuzhang/go.lib/go.mod:8: require github.com/xxx-devops/xx1/sdk/go: version "v2.2.3" invalid: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v2
于是我换个写法:
require (
github.com/xxx-devops/xx1/sdk/go v2.2.3+incompatible
)
错误信息变为:
go list -m: github.com/xxx-devops/xx1/sdk/[email protected]+incompatible: invalid version: +incompatible suffix not allowed: module contains a go.mod file, so semantic import versioning is required
解决的办法如下:
require (
github.com/xxx-devops/xx1/sdk/go/v2 v2.2.3
)
然后编译,然后go.mod文件变成了:
require (
github.com/xxx-devops/xx1/sdk/go v0.0.0-20201126031658-a2b707072c79
github.com/xxx-devops/xx1/sdk/go/v2 v2.2.3
)
然后注释掉后面一行,搞定。
结论:
1.库还是要避免太深的路径
2.为什么目录中包含个v2,一定要写到go.mod里面去?这里还没搞懂
|
请发表评论