make colons optional in text parser. (missed update in google-internal code)
add test.
R=dsymonds, dsymonds1
http://codereview.appspot.com/1733042
diff --git a/proto/text_parser.go b/proto/text_parser.go
index f888f9b..4c0166f 100644
--- a/proto/text_parser.go
+++ b/proto/text_parser.go
@@ -304,13 +304,16 @@
// those three become *T, *string and []T respectively, so we can check for
// this field being a pointer to a non-string.
typ := st.Field(fi).Type
- pt, ok := typ.(*reflect.PtrType)
- if !ok {
- break
- }
- _, ok = pt.Elem().(*reflect.StringType)
- if ok {
- break
+ if pt, ok := typ.(*reflect.PtrType); ok {
+ // *T or *string
+ if _, ok := pt.Elem().(*reflect.StringType); ok {
+ break
+ }
+ } else if st, ok := typ.(*reflect.SliceType); ok {
+ // []T or []*T
+ if _, ok := st.Elem().(*reflect.PtrType); !ok {
+ break
+ }
}
needColon = false
}