# Slices Package: Binary Search

DevFeed: [Slices Package: Binary Search](<https://devfeed.tech/articles/slices-package-binary-search-22224.md>)

Original publisher: [Read original article](<https://www.ardanlabs.com/blog/2023/08/golang-slices-binary-search.html>)

Published: 2023-08-02T00:00:00Z

Content type: tutorial

Language: en

Sources: [William Kennedy](<https://devfeed.tech/sources/william-kennedy.md>)

Topics: [Go Language](<https://devfeed.tech/topics/go-language.md>), [Algorithms](<https://devfeed.tech/topics/algorithms.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [algorithm](<https://devfeed.tech/tags/algorithm.md>), [code](<https://devfeed.tech/tags/code.md>), [data-structure](<https://devfeed.tech/tags/data-structure.md>), [go](<https://devfeed.tech/tags/go.md>), [golang](<https://devfeed.tech/tags/golang.md>), [tutorial](<https://devfeed.tech/tags/tutorial.md>)

## AI overview

A tutorial on using the experimental Go slices package for binary search. It explains binary search on sorted slices, its O(log N) average time complexity, and the package APIs for searches with and without a custom comparison function.

## Source excerpt

Series Here are all the posts in this series about the slices package. Binary Search Clip, Clone, and Compact Compare Contains, Delete, and Equal Introduction Go's most important data structure is the slice and it was designed from the beginning to be mechanically sympathetic with the hardware. To learn more about that, check out Bill Kennedy's Ultimate Go video. Thanks to the introduction of generics in Go 1.18, the language team has been experimenting with a new package called slices. This package provides an API that provides various functions that are useful when working with slices.