go mod特定依赖包处理
source link: https://studygolang.com/articles/34124
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
go mod特定依赖包处理
wu_sphinx · 大约2小时之前 · 31 次点击 · 预计阅读时间 1 分钟 · 大约8小时之前 开始浏览自从golang原生支持go mod
以后,将golang应用依赖处理统一和标准化了,但是在使用中还是会遇到一些问题,比如以下go.mod
module github.com/wowchemy/starter-blog
go 1.14
require (
github.com/wowchemy/wowchemy-hugo-modules/wowchemy v0.0.0-20210209220000-aa4fe0c75726 // indirect
github.com/wowchemy/wowchemy-hugo-modules/wowchemy-cms v0.0.0-20210209220000-aa4fe0c75726 // indirect
)
这是我的博客使用的模板,需要依赖github.com/wowchemy/wowchemy-hugo-modules/wowchemy
,可以看到版本号v0.0.0-20210209220000-aa4fe0c75726
由tag+commit时间+commit哈希组成,因为github.com/wowchemy/starter-blog
新版本存在bug,已经在github.com/wowchemy/wowchemy-hugo-modules/wowchemy
中得到修复,所以我需要改一下依赖的版本,当然我可以去查看bug修复的日期以及commit哈希,然后拼接下go mod所支持的格式,但是总感觉不太方便,于是摸索出一种方法,通过commit哈希获取依赖的版本号,具体操作如下:
➜ curl https://goproxy.cn/github.com/wowchemy/wowchemy-hugo-modules/wowchemy/@v/3cf9f6c.info
{"Version":"v0.0.0-20210215224117-3cf9f6cdeef0","Time":"2021-02-15T22:41:17Z"}
可以看到v0.0.0-20210215224117-3cf9f6cdeef0
即是我需要的版本号,开式也很简单
|-----------------------依赖项---------------------| |-哈希-|
https://goproxy.cn/github.com/wowchemy/wowchemy-hugo-modules/wowchemy/@v/3cf9f6c.info
当然,如果能用信赖项的tag尽量用tag, 这也是go官方建议的做法。
有疑问加站长微信联系(非本文作者)
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK