Go Algorithm Search Binary Search
package main//from ww w.j a v a2 s .c o m import "fmt" func binarySearch(needle int, haystack []int) bool { low := 0 high := len(haystack) - 1 for low <= high{ median := (low + high) / 2 if haystack[median] < needle { low = median + 1 }else{ high = median - 1 } } if low == len(haystack) || haystack[low] != needle { return false } return true } func main(){ items := []int{ 11,22, 94, 250, 361, 485, 637, 790, 100} fmt.Println(binarySearch(485, items)) }