format

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package format provides interfaces and implementations for handling different configuration file formats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToOrderedMapPtr

func ToOrderedMapPtr(v any) *orderedmap.OrderedMap

ToOrderedMapPtr converts both value and pointer types of OrderedMap to a pointer. Returns nil if the value is not an OrderedMap.

Types

type Handler

type Handler interface {
	// Parse reads raw bytes and returns a generic tree structure.
	Parse(data []byte, opts ParseOptions) (any, error)

	// Serialize writes the tree back to bytes.
	Serialize(tree any, opts SerializeOptions) ([]byte, error)

	// GetPath extracts a value at the given path.
	GetPath(tree any, p path.Path) (any, bool)

	// SetPath sets a value at the given path.
	SetPath(tree any, p path.Path, value any) error
}

Handler defines the interface for configuration file format handlers.

type ParseOptions

type ParseOptions struct {
	StripComments bool // Strip comments (for JSON/JSONC)
}

ParseOptions configures parsing behavior.

type SerializeOptions

type SerializeOptions struct {
	Indent string // Indentation string (e.g., "  " or "\t")
}

SerializeOptions configures serialization behavior.

Directories

Path Synopsis
Package ini provides an INI format handler for chezmoi-split.
Package ini provides an INI format handler for chezmoi-split.
Package json provides a JSON format handler for chezmoi-split.
Package json provides a JSON format handler for chezmoi-split.
Package plaintext provides a handler for line-based plaintext config files.
Package plaintext provides a handler for line-based plaintext config files.
Package toml provides a TOML format handler for chezmoi-split.
Package toml provides a TOML format handler for chezmoi-split.

Jump to

Keyboard shortcuts

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