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/go@v2.2.3+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
)
然后注释掉后面一行,搞定。

参考2

module my_prometheus

go 1.16

require (
    github.com/prometheus/prometheus/v2 v2.8.0 // indirect
)

replace github.com/prometheus/prometheus/v2 v2.8.0 => github.com/prometheus/prometheus v1.8.2-0.20190312040920-59369491cfdf

伪序列号文章: https://jfrog.com/blog/go-big...


xxx小M
30 声望11 粉丝

暂时放一些读书笔记, 很多内容没有整理好