From: Rob Pike Date: Wed, 26 Sep 2012 05:21:07 +0000 (+1000) Subject: reflect.DeepEqual: document that empty and nil are unequal for slices X-Git-Tag: go1.1rc2~2322 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=74a7cc9bf2fcf034c5de92b9217e7fab51880e73;p=gostls13.git reflect.DeepEqual: document that empty and nil are unequal for slices Update #4133. Added a sentence of documentation to call out the behavior. R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/6572051 --- diff --git a/src/pkg/reflect/deepequal.go b/src/pkg/reflect/deepequal.go index c12e90f36c..8ca20750a9 100644 --- a/src/pkg/reflect/deepequal.go +++ b/src/pkg/reflect/deepequal.go @@ -125,6 +125,7 @@ func deepValueEqual(v1, v2 Value, visited map[uintptr]*visit, depth int) (b bool // DeepEqual tests for deep equality. It uses normal == equality where possible // but will scan members of arrays, slices, maps, and fields of structs. It correctly // handles recursive types. Functions are equal only if they are both nil. +// Note: unlike regular ==, DeepEqual distinguishes an empty slice from a nil slice. func DeepEqual(a1, a2 interface{}) bool { if a1 == nil || a2 == nil { return a1 == a2