MCPcopy Index your code
hub / github.com/coder/coder / Matches

Function Matches

cli/cliutil/levenshtein/levenshtein.go:11–19  ·  view source on GitHub ↗

Matches returns the closest matches to the needle from the haystack. The maxDistance parameter is the maximum Matches distance to consider. If no matches are found, an empty slice is returned.

(needle string, maxDistance int, haystack ...string)

Source from the content-addressed store, hash-verified

9// The maxDistance parameter is the maximum Matches distance to consider.
10// If no matches are found, an empty slice is returned.
11func Matches(needle string, maxDistance int, haystack ...string) (matches []string) {
12 for _, hay := range haystack {
13 if d, err := Distance(needle, hay, maxDistance); err == nil && d <= maxDistance {
14 matches = append(matches, hay)
15 }
16 }
17
18 return matches
19}
20
21var ErrMaxDist = xerrors.New("levenshtein: maxDist exceeded")
22

Callers 2

Test_Levenshtein_MatchesFunction · 0.92

Calls 1

DistanceFunction · 0.85

Tested by 1

Test_Levenshtein_MatchesFunction · 0.74