searchmigrate

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 5 Imported by: 1

Documentation

Overview

Package searchmigrate defines an analyzer that detects sort.Search calls that could potentially be replaced with slices.BinarySearch or slices.BinarySearchFunc.

Analyzer searchmigrate

searchmigrate: detect sort.Search that can potentially use slices.BinarySearch

This analyzer flags all calls to sort.Search(n, func...) as candidates for migration to the slices package. No auto-fix is provided because the transformation depends on the closure body and is not always straightforward.

Example:

sort.Search(len(s), func(i int) bool { return s[i] >= target })

May be replaceable with:

slices.BinarySearch(s, target)

Available since Go 1.21.

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name:     "searchmigrate",
	Doc:      "detect sort.Search that can be simplified to slices.BinarySearch",
	Requires: []*analysis.Analyzer{inspect.Analyzer},
	Run:      run,
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL