8

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

suppandi g
  • 504
  • 1
  • 5
  • 18
  • 1
    See here: https://github.com/golang/go/wiki/Modules#can-i-control-when-gomod-gets-updated-and-when-the-go-tools-use-the-network-to-satisfy-dependencies – Adrian Feb 13 '19 at 17:36

2 Answers2

1

Necro answer for anyone stumbling across this:

As of go 1.16 modules are no longer automatically bumped when using go build (etc..)

See: https://golang.org/doc/go1.16#go-command

pentaphobe
  • 337
  • 1
  • 4
  • 9
0

The go command automatically resolves non-canonical semantic versions to canonical versions or pseudo-versions.

v1.4 is not a canonical semantic version.

bcmills
  • 4,391
  • 24
  • 34