Skip to content
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

Closed
wants to merge 4 commits into from
Closed

Draft: add tests for generator #7

wants to merge 4 commits into from

Conversation

czabaj
Copy link
Collaborator

@czabaj czabaj commented Mar 7, 2022

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.

- add semicolons
- remove blank line before the closing bracket
}
return plugin_go.CodeGeneratorRequest{
ProtoFile: []*descriptorpb.FileDescriptorProto{
{Syntax: &syntax, EnumType: file.EnumType, MessageType: file.MessageType},
Copy link
Collaborator Author

@czabaj czabaj Mar 7, 2022

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?

Copy link
Collaborator Author

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
Copy link
Collaborator Author

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.

@czabaj
Copy link
Collaborator Author

czabaj commented Sep 17, 2024

Closing as obsoleted

@czabaj czabaj closed this Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant