protobuf-go/cmd/protoc-gen-go/testdata/protoeditions/enum.proto
Lasse Folger 2040e8671b all: implement Go-specific GenerateLegacyUnmarshalJSON
This change adds the first Go specific editions feature and the
associated proto. The feature is used to control if the legacy
UnmarshalJSON method should be generated for enums. This change only
affects protos using editions.

More tests will be added in a followup change.

Change-Id: Ifb62454d7568bd6d90d0b93f8953adcfe46c45fd
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/561938
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Lasse Folger <lassefolger@google.com>
2024-02-12 13:54:51 +00:00

67 lines
1.3 KiB
Protocol Buffer

// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
edition = "2023";
package goproto.protoc.protoeditions;
import "reflect/protodesc/proto/go_features.proto";
option go_package = "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/protoeditions";
option features.enum_type = CLOSED;
// EnumType1 comment.
enum EnumType1 {
// EnumType1_ONE comment.
ONE = 1;
// EnumType1_TWO comment.
TWO = 2;
}
enum EnumType2 {
option allow_alias = true;
duplicate1 = 1;
duplicate2 = 1;
reserved RESERVED1;
reserved RESERVED2;
reserved 2, 3;
}
message EnumContainerMessage1 {
EnumType2 default_duplicate1 = 1 [default = duplicate1];
EnumType2 default_duplicate2 = 2 [default = duplicate2];
// NestedEnumType1A comment.
enum NestedEnumType1A {
// NestedEnumType1A_VALUE comment.
NESTED_1A_VALUE = 0;
}
enum NestedEnumType1B {
NESTED_1B_VALUE = 0;
}
message EnumContainerMessage2 {
// NestedEnumType2A comment.
enum NestedEnumType2A {
// NestedEnumType2A_VALUE comment.
NESTED_2A_VALUE = 0;
}
enum NestedEnumType2B {
NESTED_2B_VALUE = 0;
}
}
}
enum LegacyUnmarshalJSONTest {
option features.(google.protobuf.go).legacy_unmarshal_json_enum = true;
FOO = 0;
BAR = 1;
BAZ = 4;
}