MCPcopy Create free account
hub / github.com/goccy/go-yaml / encodeArray

Method encodeArray

encode.go:623–638  ·  view source on GitHub ↗
(ctx context.Context, value reflect.Value)

Source from the content-addressed store, hash-verified

621}
622
623func (e *Encoder) encodeArray(ctx context.Context, value reflect.Value) (*ast.SequenceNode, error) {
624 if e.indentSequence {
625 e.column += e.indentNum
626 defer func() { e.column -= e.indentNum }()
627 }
628 column := e.column
629 sequence := ast.Sequence(token.New("-", "-", e.pos(column)), e.isFlowStyle)
630 for i := 0; i < value.Len(); i++ {
631 node, err := e.encodeValue(ctx, value.Index(i), column)
632 if err != nil {
633 return nil, err
634 }
635 sequence.Values = append(sequence.Values, node)
636 }
637 return sequence, nil
638}
639
640func (e *Encoder) encodeMapItem(ctx context.Context, item MapItem, column int) (*ast.MappingValueNode, error) {
641 k := reflect.ValueOf(item.Key)

Callers 1

encodeValueMethod · 0.95

Calls 6

posMethod · 0.95
encodeValueMethod · 0.95
SequenceFunction · 0.92
NewFunction · 0.92
LenMethod · 0.80
IndexMethod · 0.80

Tested by

no test coverage detected