suggest

package
v1.0.100 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package suggest provides the shared "did you mean" primitives: a rune-aware Levenshtein edit distance and a prefix-weighted Closest ranker. It is the single home for these so cmd, cmd/event, and internal/cmdpolicy stop each carrying their own copy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Closest

func Closest(typed string, candidates []string, maxN int) []string

Closest returns up to maxN of candidates that plausibly match typed, ranked by shared-prefix length (desc) then edit distance (asc), keeping only reasonably-close ones.

Shared prefix is weighted first on purpose: hallucinated names are often semantically close but lexically far (e.g. "+cells-find" vs "+cells-search", "--with-styles" vs nothing close), where the common prefix is the strongest signal of intent that raw edit distance misses.

A hallucinated name is also often a compound welded from real names ("sql-file" from "sql" + "file"). Prefix and edit distance both miss the trailing half: "file" shares no prefix with "sql-file" and sits 4 edits away, past the budget, so the one candidate naming what the caller actually wanted got dropped while the leading half survived on prefix alone. Segment-exact candidates are therefore always plausible, however far the whole string drifted.

func Levenshtein

func Levenshtein(a, b string) int

Levenshtein computes the classic edit distance between two strings. It is rune-aware, so it is correct for multi-byte input.

Types

This section is empty.

Jump to

Keyboard shortcuts

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