diff options
author | Suyash <dextrous93@gmail.com> | 2016-09-16 19:54:44 +0530 |
---|---|---|
committer | Joe Tsai <thebrokentoaster@gmail.com> | 2016-09-17 00:14:19 +0000 |
commit | f7e49f6644bde3f17b4a795218a35876347455a1 (patch) | |
tree | 1fa7b3cb52466b18edfb4042944c7ac0b4716dde /src/sort | |
parent | 569340ebafcd20c01227ed9cbeb5ccd29c52f2bc (diff) | |
download | go-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.go | 2 |
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) |