letmegrpc icon indicating copy to clipboard operation
letmegrpc copied to clipboard

Issues generating multiple files from same package

Open MSalopek opened this issue 6 years ago • 7 comments

Hi, Conflicts happen after generating separate files that are a part of the same package. Such generated files have functions and variables with the same name which causes issues.

Example: Lets say I have 2 files in "package example" named ex1.proto and ex2.proto. When I run protoc --letmegrpc (...) I get var Header, var Footer, and function func NewHandler defined in both ex1.letmegrpc.go and ex2.letmegrpc.go which causes issues.

I may have a workaround for this issue.

MSalopek avatar Mar 14 '18 12:03 MSalopek

Have you tried passing both ex1.proto and ex2.proto to letmegrpc at the same time?

awalterschulze avatar Mar 14 '18 13:03 awalterschulze

Yes. I pass it like this: protoc --letmegrpc_out=./internal/types -I $(pwd)/protos $(pwd)/protos/*

MSalopek avatar Mar 14 '18 14:03 MSalopek

Damn, my bad, I never ran into this use case. Good catch, thanks for reporting and fixing :)

awalterschulze avatar Mar 17 '18 12:03 awalterschulze

Is there a solution to this yet?

I have one .proto which wraps around the other in the same package, but attempting to compile both with gogo and the wrapper with letmegrpc makes it say no Go files in /usr/lib/golang/src/protos

con-ji avatar Jun 07 '18 21:06 con-ji

Hmmm, I wonder why I thought this was fixed. It seems it is not.

A pull request to fix this would be most welcome

awalterschulze avatar Jun 08 '18 04:06 awalterschulze

My bad, it seems to work fine when invoking protoc with the proper paths set. I was able to work around the repeated fields by only compiling the main .proto with --letmegrpc_out, then removing the import import _ ".". It's a little bit hacky, but it works.

con-ji avatar Jun 08 '18 18:06 con-ji

Ooo yeah that is quite hacky. We are very open to a pull request for a fix. But either way thanks for sharing the work around.

awalterschulze avatar Jun 09 '18 10:06 awalterschulze