📝 Added basic README.md

This commit is contained in:
Maxim Lebedev 2022-01-07 00:36:27 +05:00
parent 997f82740f
commit c17bcb1a1d
1 changed files with 61 additions and 0 deletions

61
README.md Normal file
View File

@ -0,0 +1,61 @@
# tree
The fast and simple [Tree Notation](https://faq.treenotation.org/spec/) parser.
Clean and unfiltered Go with single memory allocation and without any 3rd party
dependencies.
## Usage
```go
package main
import (
"fmt"
"log"
"os"
"path/filepath"
"source.toby3d.me/toby3d/tree"
)
func main() {
// For example, load tree content from file.
file, err := os.Open(filepath.Join(".", "html.example"))
if err != nil {
log.Fatalf("cannot open file: %v", err)
}
defer file.Close()
// Parse file contents from plain Tree Notation into *tree.Node with
// *tree.Node childrens.
node := tree.Parse(file)
fmt.Printf("%#v", node)
// Output:
// html
// body
// div おはようございます
}
```
See package documentation and another examples
[on pkg.go.dev](https://pkg.go.dev/source.toby3d.me/toby3d/tree).
## Benchmark
```bash
$ GOMAXPROCS=1 go test -bench=Parse -benchmem -benchtime=10s
goos: linux
goarch: amd64
pkg: source.toby3d.me/toby3d/tree
cpu: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
BenchmarkParse 37139248 316.9 ns/op 4096 B/op 1 allocs/op
```
## License
See [LICENSE.md](LICENSE.md)
## Contact
Check [my website](https://toby3d.me/) or [just drop email](mailto:hey@toby3d.me).