Documentation ¶
Overview ¶
Package yamlconv implements utility routines for manipulating yaml struct which converted from YAML-encoded string.
Index ¶
- Variables
- func MarshalJson(data interface{}, keys []string) ([]byte, error)
- func Print(data interface{}, tab string)
- func Search(data interface{}, keys []string) (interface{}, error)
- func Subtract(data interface{}, keys []string) (interface{}, error)
- func UnmarshalJson(data interface{}, keys []string, v any) error
- type IndexOutOfRangeError
- type InvalidIndexError
- type NotFoundError
- type SearchKeyTooLongError
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func MarshalJson ¶
MarshalJson returns the JSON encoding of the sub yaml struct data. keys are used to filter the match sub yaml struct. a key in kyes must be a form of below: - '[' Unsigned Integer ']', e.g. '[0]', '[10]', etc - any string that can be used as golang map[] key.
func Print ¶
func Print(data interface{}, tab string)
Print prints the YAML-encoded string from the yaml struct data to the standard out. tab is used to spacing the nested yaml structures.
func Search ¶
Search returns the match sub-struct of yaml struct data. keys are used to filter the match sub yaml struct. a key in kyes must be a form of below: - '[' Unsigned Integer ']', e.g. '[0]', '[10]', etc - any string that can be used as golang map[] key.
It returns the same yaml struct, if the keys is empty.
An error is returned if there are no match keys or the length of keys are longer than the one of nesting of yaml struct data.
func Subtract ¶ added in v1.0.1
Subtract returns the modified yaml struct data. keys are used to filter out the matching sub yaml struct. a key in kyes must be a form of below: - '[' Unsigned Integer ']', e.g. '[0]', '[10]', etc - any string that can be used as golang map[] key.
It returns the same yaml struct, if the keys is empty.
An error is returned if there are no match keys or the length of keys are longer than the one of nesting of yaml struct data.
func UnmarshalJson ¶
UnmarshalJson parses the yaml struct data and stores the result in the value pointed to by v. keys are used to filter the match sub yaml struct. a key in kyes must be a form of below: - '[' Unsigned Integer ']', e.g. '[0]', '[10]', etc - any string that can be used as golang map[] key.
If v is nil or not a pointer, it returns an InvalidUnmarshalError.
Types ¶
type IndexOutOfRangeError ¶
type IndexOutOfRangeError struct {
Err error
}
func (*IndexOutOfRangeError) Error ¶
func (e *IndexOutOfRangeError) Error() string
func (*IndexOutOfRangeError) Unwrap ¶ added in v1.0.2
func (e *IndexOutOfRangeError) Unwrap() error
type InvalidIndexError ¶
type InvalidIndexError struct {
Err error
}
func (*InvalidIndexError) Error ¶
func (e *InvalidIndexError) Error() string
func (*InvalidIndexError) Unwrap ¶ added in v1.0.2
func (e *InvalidIndexError) Unwrap() error
type NotFoundError ¶
type NotFoundError struct {
Err error
}
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
func (*NotFoundError) Unwrap ¶ added in v1.0.2
func (e *NotFoundError) Unwrap() error
type SearchKeyTooLongError ¶
type SearchKeyTooLongError struct {
Err error
}
func (*SearchKeyTooLongError) Error ¶
func (e *SearchKeyTooLongError) Error() string
func (*SearchKeyTooLongError) Unwrap ¶ added in v1.0.2
func (e *SearchKeyTooLongError) Unwrap() error