Discover Packages
github.com/wdvn/weed
core
ds
radix
package
Version:
v0.0.2
Opens a new window with list of versions in this module.
Published: May 9, 2026
License: MIT
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
Documentation
¶
SplitPath splits a URL path into segments by '/' and ignores empty segments.
Catch-all segments (*filepath) stop further splitting.
Param represents a URL parameter captured during tree search (e.g., :id → {Key:"id", Value:"123"}).
Params is a slice of URL parameters.
Get returns the value of the parameter with the given key.
type Tree[T any ] struct {
}
Tree is a generic radix tree (trie) for storing values keyed by URL paths.
T is the type of value stored at each route endpoint.
New creates a new empty Tree.
func (t *Tree [T]) Collect() []T
Collect returns all stored values by DFS traversal of the tree.
Insert sets the value at the given path, overwriting any existing value.
Search finds a value at the given path, populating params for :param and *catch-all segments.
Returns a pointer to the value and true if found, nil and false otherwise.
func (t *Tree [T]) Upsert(path string , value T, merge func(existing *T, incoming T))
Upsert inserts a new value or updates an existing one using the merge function.
If the path already has a value, merge(existing, incoming) is called instead of overwriting.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.