goprotobuf: Introduce new proto.Message type.
Every generated protocol buffer type now implements the proto.Message interface,
which means we can add some compile-time type safety throughout the API
as well as drop a bunch of error cases.
R=r, rsc
CC=golang-dev
http://codereview.appspot.com/6298073
diff --git a/proto/equal.go b/proto/equal.go
index 40e40d4..5cde0a4 100644
--- a/proto/equal.go
+++ b/proto/equal.go
@@ -43,8 +43,7 @@
/*
Equal returns true iff protocol buffers a and b are equal.
-The arguments must both be protocol buffer structs,
-or both be pointers to protocol buffer structs.
+The arguments must both be pointers to protocol buffer structs.
Equality is defined in this way:
- Two messages are equal iff they are the same type,
@@ -65,7 +64,7 @@
The return value is undefined if a and b are not protocol buffers.
*/
-func Equal(a, b interface{}) bool {
+func Equal(a, b Message) bool {
v1, v2 := reflect.ValueOf(a), reflect.ValueOf(b)
if v1.Type() != v2.Type() {
return false
@@ -182,7 +181,7 @@
if m1 != nil && m2 != nil {
// Both are unencoded.
- if !Equal(m1, m2) {
+ if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2)) {
return false
}
continue
@@ -210,7 +209,7 @@
log.Printf("proto: badly encoded extension %d of %v: %v", extNum, base, err)
return false
}
- if !Equal(m1, m2) {
+ if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2)) {
return false
}
}