Skip to content

Instantly share code, notes, and snippets.

@kavu
Created October 27, 2013 13:19
Show Gist options
  • Select an option

  • Save kavu/7181995 to your computer and use it in GitHub Desktop.

Select an option

Save kavu/7181995 to your computer and use it in GitHub Desktop.
func IsInSlice(slice []int, searching int) bool {
intSlice := make(sort.IntSlice, len(slice))
copy(intSlice, slice)
sort.Sort(intSlice)
return sort.SearchInts(intSlice, searching) < len(slice)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment