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
392 stars 131 forks source link

proto: file "steammessages_base.proto" has a name conflict over CMsgProtoBufHeader #124

Open jannislehmann opened 2 years ago

jannislehmann commented 2 years ago

Hey!

I really enjoy working with your library. However, with the new protobuf library from Google, I am running into the following issue:

panic: proto: file "steammessages_base.proto" has a name conflict over CMsgProtoBufHeader
        previously from: "github.com/Philipp15b/go-steam/v3/csgo/protocol/protobuf"
        currently from:  "github.com/Philipp15b/go-steam/v3/protocol/protobuf"
See https://developers.google.com/protocol-buffers/docs/reference/go/faq#namespace-conflict

This seems to be caused by the default init in the protobuf packages. Since both the csgo/protocol/protobuf and the protocol/protobuf package declare the same base protobufs, there seems to be a conflict.

I am only importing github.com/Philipp15b/go-steam/v3/csgo/protocol/protobuf in my code. But I would guess that the other package is being imported automatically by a package in the background.

Does anyone have a idea how to fix that issue? Merging the protobufs into one directory would be a solution, but not the prettiest solution.

Update: I guess that a fix could be implemented in this projects generator. We should try to use the same base protobufs and not duplicate the definitions.

Philipp15b commented 2 years ago

Hi! That seems to be a serious problem, thanks for reporting. Since there are actually multiple declarations of e.g. CMsgProtoBufHeader in the .proto files, I fear it may be very fiddly to update the generator to handle these. For underworlds, there is even a different declaration with the same name (we don't generate for underworlds yet, but still).

It might be easier to pass different package names to the generator (https://developers.google.com/protocol-buffers/docs/reference/go-generated#package). This may have some side-effects which I'm not sure I understand completely, but it should fix the naming conflict. What do you think?

jannislehmann commented 2 years ago

First of all, thanks for the quick follow-up. I haven't had the time to look at the generator thoroughly, but I agree that it seems rather difficult to implement a way of merging duplicate protobufs.

Changing the package names should at least work and would definitely be worth a try. I don't even think that there will be many or even any side-effects, but I am not too familiar with the code base, yet.

jannislehmann commented 2 years ago

Just a quick update. I have tested my application with the GOLANG_PROTOBUF_REGISTRATION_CONFLICT=warn go run main.go env var. This worked for both logging into the Steam network and working with the CSGO GameCoordinator. This might not be the best solution, but works as a workaround at least.

From that experiment, I think, changing the package names, should not result in side-effects actually. So this should be worth a try.