fuzzy

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Resolve

func Resolve(query string, names []string, threshold int) (string, error)

Resolve is a convenience wrapper that returns the matched name or an error. It prints a numbered list to stdout when multiple candidates are found.

Types

type MatchResult

type MatchResult struct {
	// Exact is true when query matched a single name exactly (case-insensitive).
	Exact bool
	// Matched is the best single match when confidence is above threshold.
	Matched string
	// Candidates lists all names that scored above threshold when multiple matched.
	Candidates []string
}

MatchResult describes the outcome of a fuzzy match attempt.

func Match

func Match(query string, names []string, threshold int) (MatchResult, error)

Match resolves a partial query against a list of registered repo names. threshold is a value between 1 and 100 (default 50).

Returns:

  • MatchResult{Exact: true, Matched: name} for an exact (case-insensitive) hit.
  • MatchResult{Matched: name} when exactly one candidate is above threshold.
  • MatchResult{Candidates: [...] } when multiple candidates are above threshold.
  • error when no candidates are found.

Jump to

Keyboard shortcuts

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