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

Function Marshal

yaml.go:218–226  ·  view source on GitHub ↗

Marshal serializes the value provided into a YAML document. The structure of the generated document will reflect the structure of the value itself. Maps and pointers (to struct, string, int, etc) are accepted as the in value. Struct fields are only marshalled if they are exported (have an upper cas

(in interface{})

Source from the content-addressed store, hash-verified

216// yaml.Marshal(&T{F: 1}} // Returns "a: 1\nb: 0\n"
217//
218func Marshal(in interface{}) (out []byte, err error) {
219 defer handleErr(&err)
220 e := newEncoder()
221 defer e.destroy()
222 e.marshalDoc("", reflect.ValueOf(in))
223 e.finish()
224 out = e.out
225 return
226}
227
228// An Encoder writes YAML values to an output stream.
229type Encoder struct {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected