gojuno/minimock

Follow Go Modules release versioning

Closed this issue · 4 comments

The latest version (v2.1.5) causes go list and some other tools to fail:

$ go list
go: errors parsing go.mod:
/home/sergey/go/src/indeed.com/devops/snitch/go.mod:6: invalid module: github.com/gojuno/minimock should be v0 or v1, not v2 (v2.1.5)

Using one of the approaches suggested in Releasing Modules (v2 or Higher) would resolve this.

Workaround: depend on minimock using pseudo-versions as if it is not a proper go module. See this doc for details.

@deadok22

Can you please provide more details like Go version and maybe some dummy project for me to be able to reproduce it.

Also, what option do you think is the best? Since 2.x is already broken I'm thinking of:

  1. putting module github.com/gojuno/minimock/v3 to go.mod file
  2. replacing imports in all files in this repo to github.com/gojuno/minimock/v3
  3. tagging this commit as v3.0.0

Steps to reproduce:

sergey@sergey:/tmp$ go version
go version go1.11.4 linux/amd64
sergey@sergey:/tmp$ mkdir minimockv && cd minimockv
sergey@sergey:/tmp/minimockv$ export GO111MODULES=on
sergey@sergey:/tmp/minimockv$ go mod init example.com/minimockv/minimockv
go: creating new go.mod: module example.com/minimockv/minimockv
sergey@sergey:/tmp/minimockv$ go get github.com/gojuno/minimock
go: finding github.com/gojuno/minimock latest
go: downloading github.com/gojuno/minimock v0.0.0-20190617160801-48589a7befe5
sergey@sergey:/tmp/minimockv$ cat go.mod 
module example.com/minimockv/minimockv

require github.com/gojuno/minimock v0.0.0-20190617160801-48589a7befe5 // indirect

When the issue is fixed go.mod will contain an actual version, not a pseudo-version.

The approach you're thinking of seems reasonable and should work.

@deadok22 please check if everything is ok with v3

Also be aware that now minimock puts new import path to the generated code: github.com/gojuno/minimock/v3

Thanks @hexdigest! Works as expected!

Upgrade instructions:

  • $ go get github.com/gojuno/minimock/v3@v3.0.0
  • Replace all //go:generate go run github.com/gojuno/minimock/cmd/minimock strings with //go:generate go run github.com/gojuno/minimock/v3/cmd/minimock
  • Replace all non-generated github.com/gojuno/minimock/cmd/minimock imports with imports of github.com/gojuno/minimock/v3/cmd/minimock
  • go generate the affected files
  • go mod tidy