strmatch

package
v1.0.38 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BestFunc

func BestFunc[T any](query string, items []T, key func(T) string) (best T, score float64, ok bool)

Best for an arbitrary item type

func Score

func Score(query, candidate string) float64

Determines how closely query matches candidate, in [0,1], where 1 means an exact (case-insensitive) match and 0 means no (meaningful) similarity

Types

type Match

type Match struct {
	Value string  // the candidate string
	Index int     // its position in the input slice (-1 when no match)
	Score float64 // similarity to the query, in [0,1]
}

Scored candidate returned by Best / BestAbove

func Best

func Best(query string, candidates []string) (Match, bool)

Gets highest scoring candidate for query

func BestAbove

func BestAbove(query string, candidates []string, min float64) (Match, bool)

Best filtered by a minimum score

Jump to

Keyboard shortcuts

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