Documentation
¶
Index ¶
- Variables
- func AddCustomMarshaler[T any](marshal func(v reflect.Value, node *document.Node) error)
- func AddCustomUnmarshaler[T any](unmarshal func(node *document.Node, v reflect.Value) error)
- func AddCustomValueMarshaler[T any](marshal func(v reflect.Value, value *document.Value, format string) error)
- func AddCustomValueUnmarshaler[T any](unmarshal func(value *document.Value, v reflect.Value, format string) error)
- func Autoformat(r io.Reader, w io.Writer) error
- func AutoformatWithOptions(r io.Reader, w io.Writer, opts GenerateOptions) error
- func FormatError(err error) string
- func Generate(doc *document.Document, w io.Writer) error
- func GenerateWithOptions(doc *document.Document, w io.Writer, opts GenerateOptions) error
- func Marshal(v interface{}) ([]byte, error)
- func MarshalDocument(v interface{}, doc *document.Document) error
- func MarshalDocumentWithOptions(v interface{}, doc *document.Document, opts marshaler.MarshalOptions) error
- func MarshalNode(v interface{}) (*document.Node, error)
- func MarshalNodeWithOptions(v interface{}, opts marshaler.MarshalOptions) (*document.Node, error)
- func MarshalWithOptions(v interface{}, opts MarshalOptions) ([]byte, error)
- func Parse(r io.Reader) (*document.Document, error)
- func ParseWithOptions(r io.Reader, opts ParseOptions) (*document.Document, error)
- func Unmarshal(data []byte, v interface{}) error
- func UnmarshalDocument(doc *document.Document, v interface{}) error
- func UnmarshalDocumentWithOptions(doc *document.Document, v interface{}, opts UnmarshalOptions) error
- func UnmarshalNode(node *document.Node, v interface{}) error
- func UnmarshalNodeWithOptions(node *document.Node, v interface{}, opts UnmarshalOptions) error
- func UnmarshalWithOptions(data []byte, v interface{}, opts UnmarshalOptions) error
- type Decoder
- type Encoder
- type Error
- type Errors
- type GenerateOptions
- type GeneratorOptions
- type MarshalOptions
- type Marshaler
- type MarshalerOptions
- type ParseOptions
- type UnmarshalOptions
- type Unmarshaler
- type ValueMarshaler
- type ValueUnmarshaler
Constants ¶
This section is empty.
Variables ¶
var DefaultGenerateOptions = generator.DefaultOptions
var DefaultParseOptions = parser.ParseContextOptions{}
Functions ¶
func AddCustomMarshaler ¶
func AddCustomUnmarshaler ¶
func AddCustomValueMarshaler ¶
func Autoformat ¶
Autoformat parses a KDL document from r and writes a freshly formatted version to w.
func AutoformatWithOptions ¶
AutoformatWithOptions parses a KDL document from r and writes a freshly formatted version to w using the given options. PreserveFormatting is forced to false.
func FormatError ¶
FormatError returns a multi-line, human-readable diagnostic string for err. If err is an *Error or Errors with source text, the output includes a numbered source line with a caret pointing at the error column:
error: unexpected } before node entry
--> input.kdl:3:5
|
3 | foo { }
| ^
If err is any other error, FormatError returns err.Error().
func Generate ¶
Generate writes to w a well-formatted KDL document generated from doc, or a non-nil error on failure
func GenerateWithOptions ¶
GenerateWithOptions writes to w a well-formatted KDL document generated from doc, or a non-nil error on failure
func MarshalDocument ¶
func MarshalDocumentWithOptions ¶
func MarshalDocumentWithOptions(v interface{}, doc *document.Document, opts marshaler.MarshalOptions) error
func MarshalNode ¶
func MarshalNodeWithOptions ¶
func MarshalNodeWithOptions(v interface{}, opts marshaler.MarshalOptions) (*document.Node, error)
func MarshalWithOptions ¶
func MarshalWithOptions(v interface{}, opts MarshalOptions) ([]byte, error)
MarshalWithOptions returns the KDL representation of v using the specified Options, or a non-nil error on failure
func Parse ¶
Parse parses a KDL document from r and returns the parsed Document, or a non-nil error on failure
func ParseWithOptions ¶
func Unmarshal ¶
Unmarshal unmarshals KDL from data into v; v must contain a pointer type. Returns a non-nil error on failure.
func UnmarshalDocument ¶
func UnmarshalDocumentWithOptions ¶
func UnmarshalDocumentWithOptions(doc *document.Document, v interface{}, opts UnmarshalOptions) error
func UnmarshalNode ¶
func UnmarshalNodeWithOptions ¶
func UnmarshalNodeWithOptions(node *document.Node, v interface{}, opts UnmarshalOptions) error
func UnmarshalWithOptions ¶
func UnmarshalWithOptions(data []byte, v interface{}, opts UnmarshalOptions) error
UnmarshalWithOptions unmarshals KDL from data into v with the specified options; v must contain a pointer type. Returns a non-nil error on failure.
Types ¶
type Decoder ¶
type Decoder struct {
Options marshaler.UnmarshalOptions
// contains filtered or unexported fields
}
Decoder implements a decoder for KDL
func NewDecoder ¶
NewDecoder returns a Decoder that reads from r
type Encoder ¶
type Encoder struct {
Options MarshalOptions
// contains filtered or unexported fields
}
Encoder implements an encoder for KDL
func NewEncoder ¶
NewEncoder creates a new Encoder that writes to w
type Error ¶
type Error struct {
// Message is the human-readable error description.
Message string
// Span locates the error in the source text. Zero value if unknown.
Span document.Span
// Source is the original input text (or nil if unavailable).
// Retained so callers can render context snippets.
Source []byte
}
Error is a structured parse error with source location and context.
type GenerateOptions ¶
type GeneratorOptions ¶
type MarshalOptions ¶
type MarshalOptions struct {
MarshalerOptions
GeneratorOptions
}
type MarshalerOptions ¶
type MarshalerOptions = marshaler.MarshalOptions
type ParseOptions ¶
type ParseOptions = parser.ParseContextOptions
type UnmarshalOptions ¶
type UnmarshalOptions = marshaler.UnmarshalOptions
type Unmarshaler ¶
Unmarshaler provides an interface for custom unmarshaling of a node into a Go type
type ValueMarshaler ¶
ValueMarshaler provides an interface for custom marshaling of a Go type into a Value (such as a node argument or property)
type ValueUnmarshaler ¶
ValueUnmarshaler provides an interface for custom unmarshaling of a Value (such as a node argument or property) into a Go type