This library implements Radix Tree in go, the usages for this library can vary as it accepts interfaces as node item
$ go get github.com/goglue/radix
import "github.com/goglue/radix"
func main() {
tree := radix.NewTree()
tree.Add("someStringConsideredAsPath", 101)
tree.Add("someStringConsideredAsPath1", 102)
tree.Add("someStringConsideredAsPath2", 103)
value, err := tree.Get("someStringConsideredAsPath2")
if nil != err {
// check error types at the end of the document
}
val := value.(int)
println(val) // will output 102
}
- ErrNodeNotFound: Returned when passing a path and it could not be found
- ErrDuplicateNode: Returned when trying to overwrite a path value
- ErrNodeLabel: Returned when a label is not passed for the node
- ErrNodeValue: Returned when trying to define a path with a nil value
- Delete
- Replace/Update