🚀 Launch Week Day 5:Introducing Immutable Scans.Learn More →
Socket
Book a DemoInstallSign in
Socket

source.toby3d.me/toby3d/tree

Package Overview
Dependencies
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

source.toby3d.me/toby3d/tree

Go Modules
Version
v0.2.0
Version published
Created
Source

tree

Go Reference

The fast and simple Tree Notation parser. Clean and unfiltered Go with single memory allocation and without any 3rd party dependencies.

Usage

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.

Benchmark

$ 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

Contact

Check my website or just drop email.

FAQs

Package last updated on 06 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts