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

Method EncodeContext

encode.go:90–107  ·  view source on GitHub ↗

EncodeContext writes the YAML encoding of v to the stream with context.Context.

(ctx context.Context, v interface{})

Source from the content-addressed store, hash-verified

88
89// EncodeContext writes the YAML encoding of v to the stream with context.Context.
90func (e *Encoder) EncodeContext(ctx context.Context, v interface{}) error {
91 node, err := e.EncodeToNodeContext(ctx, v)
92 if err != nil {
93 return err
94 }
95 if err := e.setCommentByCommentMap(node); err != nil {
96 return err
97 }
98 if !e.written {
99 e.written = true
100 } else {
101 // write document separator
102 _, _ = e.writer.Write([]byte("---\n"))
103 }
104 var p printer.Printer
105 _, _ = e.writer.Write(p.PrintNode(node))
106 return nil
107}
108
109// EncodeToNode convert v to ast.Node.
110func (e *Encoder) EncodeToNode(v interface{}) (ast.Node, error) {

Callers 2

EncodeMethod · 0.95
MarshalContextFunction · 0.80

Calls 3

EncodeToNodeContextMethod · 0.95
PrintNodeMethod · 0.95

Tested by

no test coverage detected