Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong module path in go.mod #115

Closed
gudvinr opened this issue Mar 24, 2021 · 12 comments
Closed

Wrong module path in go.mod #115

gudvinr opened this issue Mar 24, 2021 · 12 comments

Comments

@gudvinr
Copy link

gudvinr commented Mar 24, 2021

As per documention:

If the module is released at major version 2 or higher, the module path must end with a major version suffix

Since go-steam has go.mod file at git tag v2.0.0 it must have module github.com/Philipp15b/go-steam/v2 in go.mod and not module github.com/Philipp15b/go-steam.

Because of that it cannot be shown in htttps://pkg.go.dev/ for example.

@Philipp15b
Copy link
Owner

I'm not quite sure how to fix this (go modules are somewhat new to me). I want to avoid copying everything in a new v2 subfolder - this is what I believe Git is for. If you have an easy fix, I would very much appreciate a pull request.

@Jleagle
Copy link
Contributor

Jleagle commented Apr 18, 2021

If you are referring to this https://blog.golang.org/v2-go-modules#TOC_4. I don't believe this is the suggested way of doing it. I have never seen a project with a v2 directory. I believe just appending /v2 to the URL in your go.mod should do it.

Examples:
https://github.com/gocolly/colly
https://github.com/grpc-ecosystem/grpc-gateway
https://github.com/ahmdrz/goinsta

@gudvinr
Copy link
Author

gudvinr commented Apr 18, 2021

Also replacing github.com/Philipp15b/go-steam with github.com/Philipp15b/go-steam/v2 in import path is necessary too.
etcd is suffering from this too since they added go.mod in v3.3 and didn't fix import path up until v3.5

@Philipp15b
Copy link
Owner

Thank you both! @gudvinr You mean replacing the import path in every single file that uses it?

What do you both think about just using versions like 1.x, removing version 2.0? It's a hack, but avoids a lot of ridiculously unnecessary work IMHO.

@gudvinr
Copy link
Author

gudvinr commented Apr 19, 2021

Thank you both! @gudvinr You mean replacing the import path in every single file that uses it?

That's correct

What do you both think about just using versions like 1.x, removing version 2.0

If v2 contains breaking changes, it'll break working code for v1 users after update. It should be safe to do so if it's not.
Right now there should be a little to no v2 users since go get should pull v1 because v2.0.0 tag does not have a proper module.

In theory you only need to replace import path in the library itself. Right now v2 can only be fetched either for users who use older Go version or if person manages to get code from master branch.

If v2 contains backward incompatible changes it is not unnecessary work though and should be quite trivial to do from any text editor

@Jleagle
Copy link
Contributor

Jleagle commented Apr 19, 2021

#116

@Philipp15b
Copy link
Owner

Well technically v2 contains breaking changes against v1, but those changes were already a few years old at that point. I will merge #116 though.

@Jleagle
Copy link
Contributor

Jleagle commented Apr 24, 2021

@Philipp15b Hey, any word on merging this in?

@Philipp15b
Copy link
Owner

Merged it now, thanks for the reminder.

@gudvinr
Copy link
Author

gudvinr commented Apr 27, 2021

@Philipp15b I also suggest you to add retraction for v2.0.0 and tag last commit with v2.0.1 or something like that.

It will instruct go tools to avoid v2.0.0 which contains malformed go.mod anyway and v2.0.1 can be finally retrieved through go get like you would usually do.

@Philipp15b
Copy link
Owner

@gudvinr Thanks for the pointer. I have just released https://github.com/Philipp15b/go-steam/releases/tag/v2.0.1. Hopefully everything finally works as intended.

@gudvinr
Copy link
Author

gudvinr commented May 5, 2021

Hopefully everything finally works as intended.

pkg.go.dev now showing correct version:

Version: v2.0.1 Latest
Published: May 1, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants