mattermost-community-enterp.../vendor/github.com/isacikgoz/fuzzy
Claude ec1f89217a Merge: Complete Mattermost Server with Community Enterprise
Full Mattermost server source with integrated Community Enterprise features.
Includes vendor directory for offline/air-gapped builds.

Structure:
- enterprise-impl/: Enterprise feature implementations
- enterprise-community/: Init files that register implementations
- enterprise/: Bridge imports (community_imports.go)
- vendor/: All dependencies for offline builds

Build (online):
  go build ./cmd/mattermost

Build (offline/air-gapped):
  go build -mod=vendor ./cmd/mattermost

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-17 23:59:07 +09:00
..
.gitignore Merge: Complete Mattermost Server with Community Enterprise 2025-12-17 23:59:07 +09:00
CONTRIBUTING.md Merge: Complete Mattermost Server with Community Enterprise 2025-12-17 23:59:07 +09:00
fuzzy.go Merge: Complete Mattermost Server with Community Enterprise 2025-12-17 23:59:07 +09:00
LICENSE Merge: Complete Mattermost Server with Community Enterprise 2025-12-17 23:59:07 +09:00
README.md Merge: Complete Mattermost Server with Community Enterprise 2025-12-17 23:59:07 +09:00

fuzzy

Build Status Documentation

Originally developed by Sahil Muthoo, fuzzy is a fuzzy search library that provides extensive searching for strings. It is optimized for filenames and code symbols. This library is external dependency-free. It only depends on the Go standard library. This fork is an parallel version of its original repository.

Features

  • Intuitive matching. Results are returned in descending order of match quality. Quality is determined by:

    • The first character in the pattern matches the first character in the match string.
    • The matched character is camel cased.
    • The matched character follows a separator such as an underscore character.
    • The matched character is adjacent to a previous match.
  • Speed. Matches are returned in milliseconds. It's perfect for interactive search boxes.

  • The positions of matches are returned. Allows you to highlight matching characters.

  • Unicode aware.

  • Works parallel.

Usage

The following example prints out matches with the matched chars in bold.

package main

import (
	"fmt"
	"sort"

	"github.com/isacikgoz/fuzzy"
)

func main() {
	const bold = "\033[1m%s\033[0m"
	pattern := "mnr"
	data := []string{"game.cpp", "moduleNameResolver.ts", "my name is_Ramsey"}

	results := Find(context.Background(),pattern, data)

	matches := make([]Match, 0)
	for result := range results {
		matches = append(matches, result)
	}

	sort.Stable(fuzzy.Sortable(matches))

	for _, match := range matches {
		for i := 0; i < len(match.Str); i++ {
			if contains(i, match.MatchedIndexes) {
				fmt.Print(fmt.Sprintf(bold, string(match.Str[i])))
			} else {
				fmt.Print(string(match.Str[i]))
			}
		}
		fmt.Println()
	}
}

func contains(needle int, haystack []int) bool {
	for _, i := range haystack {
		if needle == i {
			return true
		}
	}
	return false
}

Check out the godoc for detailed documentation.

Installation

go get github.com/isacikgoz/fuzzy

Speed

Here are a few benchmark results on a normal laptop.

BenchmarkFind/with_unreal_4_(~16K_files)-12         	     171	   6941671 ns/op	   21341 B/op	     886 allocs/op
BenchmarkFind/with_linux_kernel_(~60K_files)-12     	      76	  15827954 ns/op	    6286 B/op	     195 allocs/op

Contributing

Everyone is welcome to contribute. Please send me a pull request or file an issue.

Credits

  • @sahilm for the original project.

  • @ericpauley & @lunixbochs contributed Unicode awareness and various performance optimisations.

  • The algorithm is based of the awesome work of forrestthewoods. See this blog post for details of the algorithm.