Documentation
¶
Index ¶
- Constants
- Variables
- func Marshal[T codec.Data](in any, opts ...Options) (T, error)
- func MustMarshal[T codec.Data](in any, opts ...Options) T
- func MustUnmarshal[V any, T codec.Data](in T, opts ...Options) (v V)
- func Unmarshal[T codec.Data](in T, out any, opts ...Options) error
- type Decoder
- type Encoder
- type Kind
- type Node
- type Options
- type Style
Constants ¶
View Source
const ( DocumentNode = yaml.DocumentNode SequenceNode = yaml.SequenceNode MappingNode = yaml.MappingNode ScalarNode = yaml.ScalarNode AliasNode = yaml.AliasNode TaggedStyle = yaml.TaggedStyle DoubleQuotedStyle = yaml.DoubleQuotedStyle SingleQuotedStyle = yaml.SingleQuotedStyle LiteralStyle = yaml.LiteralStyle FoldedStyle = yaml.FoldedStyle FlowStyle = yaml.FlowStyle )
节点类型和输出样式沿用上游常量,语法树调用方无需直接依赖上游包。
Variables ¶
View Source
var ( NewEncoder = yaml.NewEncoder NewDecoder = yaml.NewDecoder )
NewEncoder 和 NewDecoder 是 go.yaml.in/yaml/v3 对应函数的别名,用于面向 io.Writer 和 io.Reader 的流式多文档编解码;Encoder 使用后必须调用 Close,否则剩余数据不会写入 Writer。
Functions ¶
Types ¶
type Options ¶ added in v1.6.2
type Options func(*options)
Options 配置编解码行为,后面的同名选项覆盖前面的选项;不适用于当前方向的选项被忽略。
func WithCompactSeqIndent ¶ added in v1.6.2
WithCompactSeqIndent 仅序列化生效:控制序列标记 "- " 是否计入缩进,默认关闭。
func WithIndent ¶ added in v1.6.2
WithIndent 仅序列化生效:设置缩进空格数,0 使用上游默认值,负数在序列化时触发 panic。
func WithKnownFields ¶ added in v1.6.2
WithKnownFields 仅反序列化生效:检查映射键是否对应目标结构体字段,默认关闭,不限制 map 的键。
Click to show internal directories.
Click to hide internal directories.