阻止go build覆盖go.mod中的版本 [英] Prevent go build from overwriting version in go.mod
问题描述
我有一个go模块,可以导入项目foo.foo的最新标签显示为v1.4
当我在项目中执行 go 时,它将更新go.mod以表示
模块github.com/myid/mymod要求 (github.com/myid/foo v1.4)
我希望它使用master分支而不是v1.4标签...所以我做了一个获取github.com/myid/foo@master
并下载pkg中的master分支,并将go.mod更新为
require(github.com/myid/foo v1-XXXXXXX-XXXXXXX)
我确认哈希与主哈希相同
但是当我再次执行 go
时,它会更新回最新的标签.
如何使用master分支而不切换回v1.4?
谢谢
go
命令自动解决非规范的伪版本./p>
v1.4
不是规范的语义版本.
I have a go module that imports project foo. foo's latest tag says v1.4
when i do a go build
in my project, it updates go.mod to say
module github.com/myid/mymod
require (
github.com/myid/foo v1.4
)
I want it to use the master branch instead of v1.4 tag...so i did a
go get github.com/myid/foo@master
and it downloaded the master branch in pkg and updated go.mod to say
require (
github.com/myid/foo v1-XXXXXXX-XXXXXXX
)
I verify that the hash is the same as master
but when i do go build
again, it gets updated back to the latest tag.
how do i get it to use the master branch and not switch back to v1.4?
Thanks
The go
command automatically resolves non-canonical semantic versions to canonical versions or pseudo-versions.
v1.4
is not a canonical semantic version.
这篇关于阻止go build覆盖go.mod中的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!