Philipp15b / go-steam

Steam's protocol in Go to allow automation of different actions on the Steam network without running an actual Steam client. Includes APIs for friends, chatting, trading, trade offers and TF2 crafting.
https://pkg.go.dev/github.com/Philipp15b/go-steam/v3
Other
387 stars 131 forks source link

Wrong module path in go.mod #115

Closed gudvinr closed 3 years ago

gudvinr commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

https://github.com/Philipp15b/go-steam/pull/116

Philipp15b commented 3 years ago

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 commented 3 years ago

@Philipp15b Hey, any word on merging this in?

Philipp15b commented 3 years ago

Merged it now, thanks for the reminder.

gudvinr commented 3 years ago

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

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

Hopefully everything finally works as intended.

pkg.go.dev now showing correct version:

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