Documentation
¶
Index ¶
- func CreateMapNode(pairs ...interface{}) (*yaml.Node, error)
- func CreateScalarNode(value string) *yaml.Node
- func CreateSequenceNode(items ...*yaml.Node) *yaml.Node
- func DeepCopyNode(node *yaml.Node) *yaml.Node
- func GetNodeAtPath(root *yaml.Node, path ...string) (*yaml.Node, error)
- func GetValueByPath(root *yaml.Node, path ...string) (interface{}, error)
- func SetComment(node *yaml.Node, comment string, position CommentPosition)
- type CommentPosition
- type YAMLEditor
- func (e *YAMLEditor) AppendToSequence(node *yaml.Node, path ...string) error
- func (e *YAMLEditor) CreateMap(pairs ...interface{}) (*yaml.Node, error)
- func (e *YAMLEditor) CreateScalar(value string) *yaml.Node
- func (e *YAMLEditor) CreateSequence(items ...*yaml.Node) *yaml.Node
- func (e *YAMLEditor) CreateValueNode(value interface{}) (*yaml.Node, error)
- func (e *YAMLEditor) DeepCopyNode(node *yaml.Node) *yaml.Node
- func (e *YAMLEditor) GetMapNode(key string, mapNode *yaml.Node) (*yaml.Node, error)
- func (e *YAMLEditor) GetNode(path ...string) (*yaml.Node, error)
- func (e *YAMLEditor) RemoveFromSequence(index int, path ...string) error
- func (e *YAMLEditor) Save(filename string) error
- func (e *YAMLEditor) SetNode(node *yaml.Node, path ...string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateMapNode ¶
func CreateMapNode(pairs ...interface{}) (*yaml.Node, error)
CreateMapNode creates a new mapping node with the given key-value pairs
func CreateScalarNode ¶
func CreateScalarNode(value string) *yaml.Node
CreateScalarNode creates a new scalar node with the given value
func CreateSequenceNode ¶
func CreateSequenceNode(items ...*yaml.Node) *yaml.Node
CreateSequenceNode creates a new sequence node with the given items
func DeepCopyNode ¶
func DeepCopyNode(node *yaml.Node) *yaml.Node
DeepCopyNode creates a deep copy of a node
func GetNodeAtPath ¶
GetNodeAtPath returns the node at the given path
func GetValueByPath ¶
GetValueByPath gets a value from a YAML node by path, with type conversion
func SetComment ¶
func SetComment(node *yaml.Node, comment string, position CommentPosition)
SetComment sets a comment on a node
Types ¶
type CommentPosition ¶
type CommentPosition int
CommentPosition specifies where to place a comment relative to a node
const ( CommentHead CommentPosition = iota // Comment before the node CommentLine // Comment at the end of the node's line CommentFoot // Comment after the node )
type YAMLEditor ¶
type YAMLEditor struct {
// contains filtered or unexported fields
}
YAMLEditor provides utilities for manipulating YAML files while preserving comments and structure
func NewYAMLEditor ¶
func NewYAMLEditor(data []byte) (*YAMLEditor, error)
NewYAMLEditor creates a new YAMLEditor from raw YAML data
func NewYAMLEditorFromFile ¶
func NewYAMLEditorFromFile(filename string) (*YAMLEditor, error)
NewYAMLEditorFromFile creates a new YAMLEditor from a file
func (*YAMLEditor) AppendToSequence ¶
func (e *YAMLEditor) AppendToSequence(node *yaml.Node, path ...string) error
AppendToSequence appends a node to a sequence at the given path
func (*YAMLEditor) CreateMap ¶
func (e *YAMLEditor) CreateMap(pairs ...interface{}) (*yaml.Node, error)
CreateMap creates a new mapping node with the given key-value pairs
func (*YAMLEditor) CreateScalar ¶
func (e *YAMLEditor) CreateScalar(value string) *yaml.Node
CreateScalar creates a new scalar node with the given value
func (*YAMLEditor) CreateSequence ¶
func (e *YAMLEditor) CreateSequence(items ...*yaml.Node) *yaml.Node
CreateSequence creates a new sequence node with the given items
func (*YAMLEditor) CreateValueNode ¶ added in v0.1.24
func (e *YAMLEditor) CreateValueNode(value interface{}) (*yaml.Node, error)
CreateValueNode creates a new node from a value of any supported type
func (*YAMLEditor) DeepCopyNode ¶
func (e *YAMLEditor) DeepCopyNode(node *yaml.Node) *yaml.Node
DeepCopyNode creates a deep copy of a node
func (*YAMLEditor) GetMapNode ¶
func (e *YAMLEditor) GetMapNode(key string, mapNode *yaml.Node) (*yaml.Node, error)
GetMapNode returns the value node for a key in a mapping node
func (*YAMLEditor) GetNode ¶
func (e *YAMLEditor) GetNode(path ...string) (*yaml.Node, error)
GetNode returns the node at the given path
func (*YAMLEditor) RemoveFromSequence ¶
func (e *YAMLEditor) RemoveFromSequence(index int, path ...string) error
RemoveFromSequence removes a node from a sequence at the given path and index
func (*YAMLEditor) Save ¶
func (e *YAMLEditor) Save(filename string) error
Save writes the YAML content to a file
func (*YAMLEditor) SetNode ¶
func (e *YAMLEditor) SetNode(node *yaml.Node, path ...string) error
SetNode sets the node at the given path