MCPcopy
hub / github.com/go-yaml/yaml / Encode

Method Encode

yaml.go:259–271  ·  view source on GitHub ↗

Encode encodes value v and stores its representation in n. See the documentation for Marshal for details about the conversion of Go values into YAML.

(v interface{})

Source from the content-addressed store, hash-verified

257// See the documentation for Marshal for details about the
258// conversion of Go values into YAML.
259func (n *Node) Encode(v interface{}) (err error) {
260 defer handleErr(&err)
261 e := newEncoder()
262 defer e.destroy()
263 e.marshalDoc("", reflect.ValueOf(v))
264 e.finish()
265 p := newParser(e.out)
266 p.textless = true
267 defer p.destroy()
268 doc := p.parse()
269 *n = *doc.Content[0]
270 return nil
271}
272
273// SetIndent changes the used indentation used when encoding.
274func (e *Encoder) SetIndent(spaces int) {

Callers 2

TestNodeEncodeDecodeMethod · 0.95
encodeBase64Function · 0.45

Calls 7

handleErrFunction · 0.85
newEncoderFunction · 0.85
newParserFunction · 0.85
marshalDocMethod · 0.80
finishMethod · 0.80
parseMethod · 0.80
destroyMethod · 0.45

Tested by 1

TestNodeEncodeDecodeMethod · 0.76