go-trie
Package go-trie implements trie tree (or prefix tree) data structure useful
for things like prefix search/autocompletion.
For now, it supports Insert, HasWord, HasPrefix and WordsByPrefix methods.
WordsByPrefix collects all words with given prefix without usage of recursion while search.
tree := NewTrie()
t.Insert("go", "golang", "gopher", "python", "pythonista", "grow", "gg", "glitch", "glass")
hasPrefix := tree.HasPrefix("gol")
hasPrefix = tree.HasPrefix("gene")
hasWord := tree.HasWord("gopher")
hasWord = tree.HasWord("foo")
words := tree.WordsByPrefix("go")