Generic prefix tree for golang
import ( "fmt" "log" "github.com/s0rg/trie" ) func main() { t := trie.New[int]() t.Add("bar", 1) t.Add("baz", 2) t.Add("bat", 3) val, ok := t.Find("bar") if !ok { log.Fatal("not found") } fmt.Println(val) // will print 1 }