mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-01-14 01:02:24 +00:00
cmd/protoc-gen-go: invert conditional check for proto syntax
To avoid accidentally emitting the UnmarshalMethod in the unlikely (but possible) event that a proto4 syntax was added, swich the conditional to only trigger on the proto2 syntax. Change-Id: I0c201eace56e9ecc92cd791e45ca5d3b99e2ba86 Reviewed-on: https://go-review.googlesource.com/c/154317 Reviewed-by: Damien Neil <dneil@google.com>
This commit is contained in:
parent
d068d302ef
commit
7390346c05
@ -334,7 +334,7 @@ func genEnum(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo, enum
|
||||
g.P("}")
|
||||
g.P()
|
||||
|
||||
if enum.Desc.Syntax() != protoreflect.Proto3 {
|
||||
if enum.Desc.Syntax() == protoreflect.Proto2 {
|
||||
g.P("func (x *", enum.GoIdent, ") UnmarshalJSON(data []byte) error {")
|
||||
g.P("value, err := ", f.protoPackage().Ident("UnmarshalJSONEnum"), "(", enum.GoIdent, `_value, data, "`, enum.GoIdent, `")`)
|
||||
g.P("if err != nil {")
|
||||
|
Loading…
Reference in New Issue
Block a user