Skip to content

Commit

Permalink
feat(genaip): add support for Protobuf Editions
Browse files Browse the repository at this point in the history
Protobuf Editions introduces a new feature flag system aimed at unifying proto2 and
proto3 functionality and semantics.

Closes #327
  • Loading branch information
vallahaye committed Jan 26, 2025
1 parent 95bdfbb commit 5300659
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/protoc-gen-go-aip/internal/genaip/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/reflect/protoregistry"
"google.golang.org/protobuf/types/descriptorpb"
"google.golang.org/protobuf/types/pluginpb"
)

// PluginName is the name of the AIP Go protobuf compiler plugin.
Expand All @@ -21,6 +23,10 @@ type Config struct {

// Run the AIP Go protobuf compiler plugin.
func Run(gen *protogen.Plugin, config Config) error {
gen.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL) |
uint64(pluginpb.CodeGeneratorResponse_FEATURE_SUPPORTS_EDITIONS)
gen.SupportedEditionsMinimum = descriptorpb.Edition_EDITION_PROTO2
gen.SupportedEditionsMaximum = descriptorpb.Edition_EDITION_2023
var files protoregistry.Files
for _, file := range gen.Files {
if err := files.RegisterFile(file.Desc); err != nil {
Expand Down

0 comments on commit 5300659

Please sign in to comment.