Go Modules

61 Go Modules、Go Module Proxy 和 goproxy.cn 【 Go 夜读 】

视频地址: https://www.bilibili.com/vide...

https://eddycjy.com/posts/go/...

在项目中的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
)
然后注释掉后面一行,搞定。

你可能感兴趣的:(golang)