Gotree is a set of convenience functions to build an in-memory tree structure in Go to organize data of any sort.
// Create a new Tree
tree := NewTree()
// Create the nodes /Machine/Heating/Zones/Zone1/SetTemperature and ActualTemperature
// (nil in lieu of the actual data)
tree.Root.InsertAtPath(
[]string{"Machine", "Heating", "Zones", "Zone1"},
[]*Node{
tree.NewNode(uuid.New(), "SetTemperature", Opc.get("V27t1")),
tree.NewNode(uuid.New(), "ActualTemperature", Opc.get("V2t87")),
}
// Is there a /robots/marvin/quotes in our tree?
needle, found := tree.Root.FindByPathTokens([]string{"robots", "marvin", "quotes"})
Please check the demo and the unittests for more examples.