goprotobuf: Fix panic in SetDefaults for nil sub-messages.

Fixes #23.

R=r
CC=golang-dev
http://codereview.appspot.com/5477071
diff --git a/proto/all_test.go b/proto/all_test.go
index 1d64610..615e88a 100644
--- a/proto/all_test.go
+++ b/proto/all_test.go
@@ -1279,7 +1279,7 @@
 	}
 	SetDefaults(m)
 	if !Equal(m, expected) {
-		t.Errorf(" got %v\nwant %v", m, expected)
+		t.Errorf("\n got %v\nwant %v", m, expected)
 	}
 }
 
diff --git a/proto/lib.go b/proto/lib.go
index 33795e9..498cb75 100644
--- a/proto/lib.go
+++ b/proto/lib.go
@@ -657,7 +657,11 @@
 	}
 
 	for _, ni := range dm.nested {
-		setDefaults(v.Field(ni), recur, zeros)
+		f := v.Field(ni)
+		if f.IsNil() {
+			continue
+		}
+		setDefaults(f, recur, zeros)
 	}
 }
 
diff --git a/proto/testdata/test.proto b/proto/testdata/test.proto
index 5acb5a8..51c047c 100644
--- a/proto/testdata/test.proto
+++ b/proto/testdata/test.proto
@@ -288,6 +288,13 @@
   optional float F_Pinf = 15 [default=inf];
   optional float F_Ninf = 16 [default=-inf];
   optional float F_Nan = 17 [default=nan];
+
+  // Sub-message.
+  optional SubDefaults sub = 18;
+}
+
+message SubDefaults {
+  optional int64 n = 1 [default=7];
 }
 
 message RepeatedEnum {