2 回答
TA贡献1851条经验 获得超3个赞
一种通过执行以下更改来更新代码的方法。
在您的项目中打开您的go.mod文件,并使用项目的最后一个提交哈希写入。helloreplacecurrent versiongithub.com/user/say_thingssay_things
换句话说,在go.mod文件中
替换github.com/user/say_things <current-version>
为github.com/user/say_things <last-commit-hash>
最后运行:
$ go mod tidy $ go mod vendor
TA贡献1802条经验 获得超10个赞
go get命令下载所需模块的新版本。例如:
% go get -u all
go: github.com/user/say_things upgrade => v0.0.0-<new hash>
– 将所有最后一个模块的版本下载到$GOPATH/pkg升级go.mod文件。
❕使用go-modules时,更好的方法是向存储库添加版本标签(tag必须符合语义版本控制规范)
git commit -a - m "say_things - some changes"
git tag v1.0.1
git push
git push --tags
这将允许您手动更改版本go.mod
module github.com/user/hello
go 1.15
require github.com/user/say_things v1.0.1
% go mod download
go: finding github.com/user/say_things v1.0.1
, 并通过版本标签获取所需版本
% go get github.com/user/say_things@v1.0.1
go: finding github.com/user/say_things v1.0.1
go: downloading github.com/user/say_things v1.0.1
go: extracting github.com/user/say_things v1.0.1
- 2 回答
- 0 关注
- 214 浏览
添加回答
举报
