fastparser

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package fastparser implements a high-performance XML parser without AST construction.

This parser is optimized for direct parsing to Go native types (map[string]interface{}). It bypasses AST construction, parsing directly from bytes to Go values for minimal overhead.

This is the "fast path" in the dual-path parser pattern. Use this for:

  • Unmarshal: Populate Go structs from XML (4-5x faster than AST path)
  • Validate: Check XML well-formedness (4-5x faster than AST path)

Performance targets (vs AST parser):

  • 4-5x faster parsing
  • 5-6x less memory
  • 4-5x fewer allocations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Unmarshal

func Unmarshal(data []byte, v interface{}) error

Unmarshal parses XML and unmarshals it into the value pointed to by v. This is the fast path that bypasses AST construction.

func UnmarshalValue

func UnmarshalValue(value interface{}, rv reflect.Value) error

UnmarshalValue unmarshals a parsed value into a reflect.Value. This is exported for use by the AST path unmarshal function.

Types

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser implements a zero-allocation XML validator that checks well-formedness without AST.

func NewParser

func NewParser(data []byte) *Parser

NewParser creates a new fast parser for the given data.

func (*Parser) Parse

func (p *Parser) Parse() (interface{}, error)

Parse parses the XML data and returns the value as interface{} (map[string]interface{}). This is used by Unmarshal and Validate. For validation, the caller can simply discard the returned value.

type Unmarshaler

type Unmarshaler interface {
	UnmarshalXML([]byte) error
}

Unmarshaler is the interface implemented by types that can unmarshal an XML description of themselves.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL