-
Notifications
You must be signed in to change notification settings - Fork 2
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
Draft: add tests for generator #7
Conversation
- add semicolons - remove blank line before the closing bracket
generator_test.go
Outdated
} | ||
return plugin_go.CodeGeneratorRequest{ | ||
ProtoFile: []*descriptorpb.FileDescriptorProto{ | ||
{Syntax: &syntax, EnumType: file.EnumType, MessageType: file.MessageType}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I struggle with passing of the pointers to the descriptorpb
, it requires all values as a pointers, which complicates the logic.
E.g. here I would like to pass a
{Syntax: "proto3"
but that yields an error, as the Syntax
expects a pointer, and I cannot create a string pointer in-place, right? So every time I want to pass a pointer, I need to declare a variable for the value which is verbose.
Is there some trick how to create e.g. a string and pass that immediately as a pointer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found a solution, using a gox
package. https://stackoverflow.com/a/30716481/2508019
baz := "baz" | ||
tNumber := descriptorpb.FieldDescriptorProto_TYPE_DOUBLE | ||
tString := descriptorpb.FieldDescriptorProto_TYPE_SFIXED64 | ||
tBool := descriptorpb.FieldDescriptorProto_TYPE_BOOL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More ad-hoc variables just to obtain pointers to them.
Closing as obsoleted |
I would like to make this generator comply with the proto3 JSON canonical encoding. To make this happen, I need a test suite that the project currently lacks.
I'm fairly new to Go lang so I struggle with the most basic things, feel free to correct me or advise a better approach to the code.