https://github.com/i78/gotree
Gotree is a set of convenience functions to build an in-memory tree structure in Go to organize data of any sort.
https://github.com/i78/gotree
Last synced: 5 months ago
JSON representation
Gotree is a set of convenience functions to build an in-memory tree structure in Go to organize data of any sort.
- Host: GitHub
- URL: https://github.com/i78/gotree
- Owner: i78
- Created: 2018-01-29T13:24:16.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-16T13:23:47.000Z (over 8 years ago)
- Last Synced: 2024-06-20T06:23:51.591Z (about 2 years ago)
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tree Data Container for Go
Gotree is a set of convenience functions to build an in-memory tree structure in Go to organize data of any sort.
## Examples
### Creating a Tree for managing machine settings
```
// 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")),
}
```
### Searching for Nodes
```
// 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.