aboutsummaryrefslogtreecommitdiff
path: root/src/sort
diff options
context:
space:
mode:
authorSuyash <dextrous93@gmail.com>2016-09-16 19:54:44 +0530
committerJoe Tsai <thebrokentoaster@gmail.com>2016-09-17 00:14:19 +0000
commitf7e49f6644bde3f17b4a795218a35876347455a1 (patch)
tree1fa7b3cb52466b18edfb4042944c7ac0b4716dde /src/sort
parent569340ebafcd20c01227ed9cbeb5ccd29c52f2bc (diff)
downloadgo-f7e49f6644bde3f17b4a795218a35876347455a1.tar.gz
go-f7e49f6644bde3f17b4a795218a35876347455a1.zip
sort: fix search descending order example
Change-Id: I27b82d8c63a06ddf7e148b15853aba24a22a6282 Reviewed-on: https://go-review.googlesource.com/29336 Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com> Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/sort')
-rw-r--r--src/sort/example_search_test.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/sort/example_search_test.go b/src/sort/example_search_test.go
index 345590cb4d..6928f0f092 100644
--- a/src/sort/example_search_test.go
+++ b/src/sort/example_search_test.go
@@ -32,7 +32,7 @@ func ExampleSearch_descendingOrder() {
x := 6
i := sort.Search(len(a), func(i int) bool { return a[i] <= x })
- if a[i] == x {
+ if i < len(a) && a[i] == x {
fmt.Printf("found %d at index %d in %v\n", x, i, a)
} else {
fmt.Printf("%d not found in %v\n", x, a)