Documentation
¶
Overview ¶
Package storage provides hierarchical configuration storage and path parsing utilities.
Features: - Storage manages key-value pairs with support for nested paths, subkey lookup, and conflict detection. - Path represents structured access paths with support for parsing (SplitPath) and construction (JoinPath). - Supports two path types:
- Key (e.g., "user.name") for map access
- Index (e.g., "[0]") for array access
- Maintains a tree structure (treeNode) for consistent and type-safe hierarchy management.
Use cases: - Accessing values in JSON/YAML/TOML-like configs - Managing nested config data (CRUD) - Validating structure and detecting conflicts
Notes: - Path syntax follows common config patterns (e.g., "users[0].profile.age") - Type-safe path handling (keys vs. indices)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Path ¶
type Path struct { Type PathType // Type determines whether the segment is a key or index. Elem string // Elem holds the actual key or index value as a string. }
Path represents a segment of a hierarchical path. Each segment is either a key (e.g., "user") or an index (e.g., "0").
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage stores hierarchical key-value pairs and tracks their structure using a tree. It supports nested paths and detects structural conflicts when paths differ in type.
func NewStorage ¶
func NewStorage() *Storage
NewStorage creates and initializes a new Storage instance.
func (*Storage) Has ¶
Has returns true if the given key exists in the storage, either as a direct value or as a valid path in the hierarchical tree structure.
func (*Storage) RawData ¶
RawData returns the underlying flat key-value map. Note: This exposes internal state; use with caution.