From: Matthew Dempsky Date: Mon, 7 Jan 2013 03:43:32 +0000 (-0500) Subject: bytes: Change Compare example to be consistent with sort.Search's. X-Git-Tag: go1.1rc2~1463 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8cf45909b59dbc9edf856b129c6b84603438973b;p=gostls13.git bytes: Change Compare example to be consistent with sort.Search's. R=rsc, adg CC=golang-dev https://golang.org/cl/7057049 --- diff --git a/src/pkg/bytes/example_test.go b/src/pkg/bytes/example_test.go index 5f7e18c9f6..dc66b6a40f 100644 --- a/src/pkg/bytes/example_test.go +++ b/src/pkg/bytes/example_test.go @@ -59,10 +59,10 @@ func ExampleCompare_search() { var needle []byte var haystack [][]byte // Assume sorted i := sort.Search(len(haystack), func(i int) bool { - // Return needle <= haystack[i]. - return bytes.Compare(needle, haystack[i]) <= 0 + // Return haystack[i] >= needle. + return bytes.Compare(haystack[i], needle) >= 0 }) - if i < len(haystack) && bytes.Equal(needle, haystack[i]) { + if i < len(haystack) && bytes.Equal(haystack[i], needle) { // Found it! } }