From 997f82740f3bc4270ee4eca904db7052c914519a Mon Sep 17 00:00:00 2001 From: Maxim Lebedev Date: Fri, 7 Jan 2022 00:32:14 +0500 Subject: [PATCH 1/3] :page_facing_up: Added license file --- LICENSE.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..a266478 --- /dev/null +++ b/LICENSE.md @@ -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. From c17bcb1a1d0b0d199bc37284738223553dd41bf9 Mon Sep 17 00:00:00 2001 From: Maxim Lebedev Date: Fri, 7 Jan 2022 00:36:27 +0500 Subject: [PATCH 2/3] :memo: Added basic README.md --- README.md | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..f9ccf49 --- /dev/null +++ b/README.md @@ -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). From a3ea5958ba5096c435ceeebf369fb6c300ac0a67 Mon Sep 17 00:00:00 2001 From: Maxim Lebedev Date: Fri, 7 Jan 2022 00:38:44 +0500 Subject: [PATCH 3/3] :memo: Added pkg.go.dev badge in README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f9ccf49..d75d967 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # 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.