gojuno / minimock

Powerful mock generation tool for Go programming language
MIT License
577 stars 38 forks source link

Follow Go Modules release versioning #37

Closed deadok22 closed 5 years ago

deadok22 commented 5 years ago

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.

hexdigest commented 5 years ago

@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
deadok22 commented 5 years ago

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.

hexdigest commented 5 years ago

@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

deadok22 commented 5 years ago

Thanks @hexdigest! Works as expected!

Upgrade instructions: