goprotobuf: Handle a non-pointer being passed to MarshalText.

R=r
CC=golang-dev
http://codereview.appspot.com/5876065
diff --git a/proto/text_test.go b/proto/text_test.go
index e720bdd..7d8adfb 100644
--- a/proto/text_test.go
+++ b/proto/text_test.go
@@ -53,11 +53,11 @@
 			Connected: proto.Bool(true),
 		},
 		Others: []*pb.OtherMessage{
-			&pb.OtherMessage{
+			{
 				Key:   proto.Int64(0xdeadbeef),
 				Value: []byte{1, 65, 7, 12},
 			},
-			&pb.OtherMessage{
+			{
 				Weight: proto.Float32(6.022),
 				Inner: &pb.InnerMessage{
 					Host: proto.String("lesha.mtv"),
@@ -221,3 +221,12 @@
 		}
 	}
 }
+
+func TestNonPtrMessage(t *testing.T) {
+	// Ensure we don't panic when we pass a non-pointer to MarshalText.
+	var buf bytes.Buffer
+	proto.MarshalText(&buf, pb.MyMessage{})
+	if s := buf.String(); s != "<struct-by-value>" {
+		t.Errorf("got: %q, want %q", s, "<struct-by-value>")
+	}
+}