fuzzysearch

package module
v0.0.0-...-a26d9b0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2022 License: MIT Imports: 2 Imported by: 0

README

Tiny and blazing-fast fuzzy search in Go

Installation

go get codeberg.org/chensl/fuzzysearch

Examples

package main

import (
	"fmt"

	"codeberg.org/chensl/fuzzysearch"
)

func main() {
	elems := []string{"cartwheel", "foobar", "wheel", "baz"}
	pattern := "whl"

	fmt.Println(fuzzysearch.Find(elems, pattern))
	// Output: [wheel cartwheel]
}

Inspired by

Documentation

Overview

Package fuzzysearch provides tiny and blazing-fast fuzzy search in Go

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Find

func Find(elems []string, pattern string) []string

Find returns all matches, sorted by levenshtein distance.

Example
elems := []string{"cartwheel", "foobar", "wheel", "baz"}
pattern := "whl"

fmt.Println(Find(elems, pattern))
Output:

[wheel cartwheel]

func Match

func Match(str, pattern string) bool

Match returns true if str matches pattern.

Example
fmt.Println(Match("cartwheel", "whl"))
Output:

true

Types

This section is empty.

Jump to

Keyboard shortcuts

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