Skip to content

Latest commit

 

History

History
48 lines (36 loc) · 1 KB

README.md

File metadata and controls

48 lines (36 loc) · 1 KB

KDLGo

GoDoc

WIP Go parser for the KDL Document Language, version 1.0.0.

Current status

  • parsing to a kdl.Document model
  • serializing a kdl.Document model to a string
  • marshalling from a struct
  • unmarshalling to a struct
  • improve performance?

Usage

import (
	kdl "github.com/frixuu/kdlgo"
)

Parse (to a Document model)

// or any of: ParseBytes, ParseFile, ParseReader
document, err := kdl.ParseString(`foo bar="baz"`)

Modify the Document

if document.Nodes[0].HasProp("bar") {
	n := kdl.NewNode("person")
	n.AddArg("known")
	// or: n.AddArgValue(kdl.NewStringValue("known", kdl.NoHint()))
	n.SetProp("name", "Joe")
	// or: n.SetPropValue("name", kdl.NewStringValue("Joe", kdl.NoHint()))
	document.AddChild(n)
}

Serialize the Document

// or Write() to an io.Writer
s, err := document.WriteString()