derekparker / trie

Data structure and relevant algorithms for extremely fast prefix/fuzzy string searching.
MIT License
761 stars 115 forks source link

FuzzySearch fails on empty string? #18

Closed amogh09 closed 5 years ago

amogh09 commented 6 years ago

Hey, kudos for the good work.

By the way, FuzzySearch fails on empty string input. I will look into your code and see if I can fix it.

package main

import "github.com/derekparker/trie"

func main() {
    t := trie.New()
    t.Add("foo", 1)
    t.FuzzySearch("")
}

Output -

panic: runtime error: index out of range

goroutine 1 [running]:
github.com/derekparker/trie.fuzzycollect(0xc000024080, 0xc000046688, 0x0, 0x20, 0x0, 0x20, 0x20)
    /home/amogh/go/src/github.com/derekparker/trie/trie.go:272 +0x4b0
github.com/derekparker/trie.Trie.FuzzySearch(0xc000024080, 0x1, 0x0, 0x0, 0x4aadf8, 0xc000024180, 0x0)
    /home/amogh/go/src/github.com/derekparker/trie/trie.go:117 +0x96
main.main()
    /home/amogh/go/src/tmp/tmp.go:8 +0xed
exit status 2