m13253 / dns-over-https

High performance DNS over HTTPS client & server
https://developers.google.com/speed/public-dns/docs/dns-over-https
MIT License
1.96k stars 221 forks source link

Go import `invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v2` #115

Closed leiless closed 2 years ago

leiless commented 2 years ago

I want to upgrade the dependency of m13253/dns-over-https to v2.2.5 of my go package, however, I got:

$ docker run -it --rm golang:1.16-buster
root@426057fa6ca9:/go# go get -v github.com/m13253/dns-over-https@v2.2.5
go get: github.com/m13253/dns-over-https@v2.2.5: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v2

It's mainly because the current Go package module isn't compliant with the Go module hierarchy.

An obvious solution would be:

SEE ALSO

https://golang.cafe/blog/how-to-upgrade-to-a-major-version-in-go.html https://archive.is/VohDN

m13253 commented 2 years ago

Oh... This is a breaking change at Go 1.16, I guess.

This software was created way before Go's new module system. I don't understand why this happen, since Go always maintained backwards compatibility in the past, until this change.

I would be very happy to receive a PR, if you have time to fix this issue.

leiless commented 2 years ago

I believe that Go updated its module system(for semver) since 1.9.7+, 1.10.3+, and 1.11

https://github.com/golang/go/wiki/Modules#semantic-import-versioning https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher https://github.com/golang/go/wiki/Modules#how-are-v2-modules-treated-in-a-build-if-modules-support-is-not-enabled-how-does-minimal-module-compatibility-work-in-197-1103-and-111

I would be very happy to receive a PR, if you have time to fix this issue.

I'll do it ASAP if I'm available.

m13253 commented 2 years ago

Thank you so much for helping me solve the issue!

I haven't been following the recent updates from Go official team for quite a long time. I'm so glad that you helped me!

leiless commented 2 years ago

You're welcome 😆, you may consider releasing a new tag(when the next release tag is stabilized), so I can refer to it(otherwise I can only use the latest HEAD commit).

m13253 commented 2 years ago

you may consider releasing a new tag

Done!