Documentation
¶
Overview ¶
Package strdist provides small string-distance helpers for typo-tolerant CLI suggestions ("did you mean X?"). Cross-cutting and project-agnostic: consumers are tools that take a name argument and want to self-correct a near-miss instead of failing silently (e.g. `sf composer show <pkg>`, flag-typo hints).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Levenshtein ¶
Levenshtein returns the edit distance between a and b (insert/delete/substitute, cost 1 each). Operates on runes, so it is correct for non-ASCII input.
func Nearest ¶
Nearest returns the candidate closest to target under a tolerance scaled to target length (≤ ⌈len/3⌉, min 1) — close enough to be a likely typo, not an unrelated word. Comparison is case-insensitive. ok is false when no candidate is within tolerance (or candidates is empty), so callers can fall back to a generic hint. Ties resolve to the first candidate in iteration order.
Types ¶
This section is empty.