-
Notifications
You must be signed in to change notification settings - Fork 48
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
invalid code is generated: conn declared and not used #34
Comments
The code is assuming you have defined some services. Also this I prefer getting compile errors vs runtime errors for my code generation when it is so complex. That is why I prefer not to use templates in the cases where I am generating a large amount of code. |
I think it's a fair requirement that there are some services given, and I actually didn't defined it properly. But it's not a valid assumption IMHO, in the sense that this it should generate an error as an invalid input was received. I think the generator should fail if file.GetService() returned no entries.
I totally agree, but I honestly don't see how this is facilitated by your generator, and impossible with templates. But I may be overlooking something here -- I haven't worked on such code generation yet. |
Would you like to contribute this error reporting? When you are using templates same for example
And you have a struct type A struct {
FirstName string
} The go compiler is not going to tell you that your struct field should be called Name and not FirstName or that your template should be changed. If someone wants to take over the maintenance of this project. I won't stand in the way of this design choice. |
I created a PR to do the error reporting, but don't have time to test it now. I think it solves the right problem and the interface is pretty, but I haven't been able to use it properly so far. |
I am trying to run letmegrpc but the generated code is incorrect:
Unfortunately there is a lot of implicit stuff going on. I found the generated file is in some /tmp/letmegrpc_ directory, and the code is indeed incorrect:
Indeed this is not correct go code.
It is generated with this code
What can we do about it?
Related question: I see the code generator uses gogo/protobuf code generator, with .In(), .Out(), etc. Is there a reason to do it like this? Would it not be much simpler to generate the code with a template, and format it with gofmt afterwards?
The text was updated successfully, but these errors were encountered: