jstemmer / go-junit-report

Convert Go test output to JUnit XML
MIT License
763 stars 222 forks source link

`go install` of version 'v2.0.0-beta1' fails with "go.mod has post-v2 module path" #136

Closed generalmimon closed 2 years ago

generalmimon commented 2 years ago
$ go version
go version go1.18.3 windows/amd64

$ go install 'github.com/jstemmer/go-junit-report@v2.0.0-beta1'
go: github.com/jstemmer/go-junit-report@v2.0.0-beta1: github.com/jstemmer/go-junit-report@v2.0.0-beta1:
invalid version: go.mod has post-v2 module path "github.com/jstemmer/go-junit-report/v2" at revision v2.0.0-beta1

I assume that the tag in go.mod should still be v1, because the stable @v2 was formally not released yet (Go apparently knows that a -beta1 version is a lower version than the stable one without the -beta suffix):

https://github.com/jstemmer/go-junit-report/blob/d84b41a3f9221d8a17cc886dfa32135baf26e86e/go.mod#L1

Even Go 1.13 (I know, indeed an old version at this point) complains about it:

$ go version
go version go1.13.15 windows/amd64

$ GO111MODULE=on go get 'github.com/jstemmer/go-junit-report@v2.0.0-beta1'
go: finding github.com v2.0.0-beta1
go: finding github.com/jstemmer/go-junit-report v2.0.0-beta1
go: finding github.com/jstemmer v2.0.0-beta1
go: finding github.com/jstemmer/go-junit-report v2.0.0-beta1
go get github.com/jstemmer/go-junit-report@v2.0.0-beta1: github.com/jstemmer/go-junit-report@v2.0.0-beta1:
invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v2
jstemmer commented 2 years ago

I noticed this too and was wondering why it happened, though I never tried to find out why. I guess a potential workaround at the moment is to append v2 to the package name (go install github.com/jstemmer/go-junit-report/v2@v2.0.0-beta1. It sounds like this should resolve itself once I release a stable v2 version?

generalmimon commented 2 years ago

@jstemmer:

It sounds like this should resolve itself once I release a stable v2 version?

I don't think so. After reading a few articles I assume it has nothing to do with whether it is a pre-release or not.

I'm not familiar with Go modules, but these articles seem relevant:

So if I understand, the source code of the v2 version is supposed to be either in a v2/ directory or on a separate v2 branch?

generalmimon commented 2 years ago

See also https://go.dev/ref/mod#minimal-module-compatibility