Correctly set OrigName for oneof fields.
Signed-off-by: David Symonds <dsymonds@golang.org>
diff --git a/proto/properties.go b/proto/properties.go
index 4fe2ec2..880eb22 100644
--- a/proto/properties.go
+++ b/proto/properties.go
@@ -701,7 +701,11 @@
if f.Name == "XXX_unrecognized" { // special case
prop.unrecField = toField(&f)
}
- oneof := f.Tag.Get("protobuf_oneof") != "" // special case
+ oneof := f.Tag.Get("protobuf_oneof") // special case
+ if oneof != "" {
+ // Oneof fields don't use the traditional protobuf tag.
+ p.OrigName = oneof
+ }
prop.Prop[i] = p
prop.order[i] = i
if debug {
@@ -711,7 +715,7 @@
}
print("\n")
}
- if p.enc == nil && !strings.HasPrefix(f.Name, "XXX_") && !oneof {
+ if p.enc == nil && !strings.HasPrefix(f.Name, "XXX_") && oneof == "" {
fmt.Fprintln(os.Stderr, "proto: no encoder for", f.Name, f.Type.String(), "[GetProperties]")
}
}