Skip to content

protoc-gen-go: support optimize_for file option #788

Open
@johanbrandhorst

Description

@johanbrandhorst

Is your feature request related to a problem? Please describe.
The default generator optimizes for code size, which is unsuitable for some use cases.

Describe the solution you'd like
I'd like the first-party optimize_for file option to be supported. As per https://developers.google.com/protocol-buffers/docs/proto3#options it would include implementing different codegen based on the 3 options:

SPEED
CODE_SIZE
LITE_RUNTIME (might not apply at all to Go files)

According to the documentation, SPEED is the default, but changing that would potentially be considered a backwards-incompatible change, so I'm happy to leave CODE_SIZE the default in that case.

Describe alternatives you've considered
Alternatives include using the gogo/protobuf project to generate message specific messages. This is widely used in industry where speed is desired over code size, and one of the major reasons for its popularity.

Additional context
This could be another opportunity to merge parts of the gogo/protobuf codebase into this repo, and potentially win back a lot of users of gogo/protobuf to the official implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    generator-proto-optioninvolves generators respecting a proto option to control generated source output

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions