Prechádzať zdrojové kódy

goprotobuf: update package doc to mention enum String methods.

R=r
CC=golang-dev
http://codereview.appspot.com/4816069
David Symonds 14 rokov pred
rodič
commit
350c58fbf0
1 zmenil súbory, kde vykonal 4 pridanie a 1 odobranie
  1. 4 1
      proto/lib.go

+ 4 - 1
proto/lib.go

@@ -53,7 +53,7 @@
 		have them.  They have the form Default_StructName_FieldName.
 	  - Enums are given type names and maps between names to values,
 	  	plus a helper function to create values.  Enum values are prefixed
-	  	with the enum's type name.
+	  	with the enum's type name. Enum types have a String method.
 	  - Nested groups and enums have type names prefixed with the name of
 	  	the surrounding message type.
 	  - Extensions are given descriptor names that start with E_,
@@ -99,6 +99,9 @@
 			e := FOO(x)
 			return &e
 		}
+		func (x FOO) String() string {
+			return proto.EnumName(FOO_name, int32(x))
+		}
 
 		type Test struct {
 			Label	*string	`protobuf:"bytes,1,req,name=label"`