package search import ( "fmt" "testing" ) type mockItem struct { path string data any } func TestNewTree(t *testing.T) { tree := NewTree() list := []mockItem{ {"/", 1}, {"/api", 2}, {"/api/v1/:name", 3}, } for _, v := range list { if err := tree.Add(v.path, v.data); err != nil { t.Error(err) } } fmt.Println(list) fmt.Println(tree.Search("/api/v1/tom")) }