🔀 Merge branch 'develop'
This commit is contained in:
commit
5dbee63a46
|
@ -0,0 +1,25 @@
|
|||
The MIT License (MIT)
|
||||
=====================
|
||||
|
||||
Copyright © 2022 Maxim Lebedev
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the “Software”), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -0,0 +1,63 @@
|
|||
# tree
|
||||
|
||||
[![Go Reference](https://pkg.go.dev/badge/source.toby3d.me/toby3d/tree.svg)](https://pkg.go.dev/source.toby3d.me/toby3d/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).
|
Loading…
Reference in New Issue