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

Method unmarshal

decode.go:484–522  ·  view source on GitHub ↗
(n *Node, out reflect.Value)

Source from the content-addressed store, hash-verified

482}
483
484func (d *decoder) unmarshal(n *Node, out reflect.Value) (good bool) {
485 d.decodeCount++
486 if d.aliasDepth > 0 {
487 d.aliasCount++
488 }
489 if d.aliasCount > 100 && d.decodeCount > 1000 && float64(d.aliasCount)/float64(d.decodeCount) > allowedAliasRatio(d.decodeCount) {
490 failf("document contains excessive aliasing")
491 }
492 if out.Type() == nodeType {
493 out.Set(reflect.ValueOf(n).Elem())
494 return true
495 }
496 switch n.Kind {
497 case DocumentNode:
498 return d.document(n, out)
499 case AliasNode:
500 return d.alias(n, out)
501 }
502 out, unmarshaled, good := d.prepare(n, out)
503 if unmarshaled {
504 return good
505 }
506 switch n.Kind {
507 case ScalarNode:
508 good = d.scalar(n, out)
509 case MappingNode:
510 good = d.mapping(n, out)
511 case SequenceNode:
512 good = d.sequence(n, out)
513 case 0:
514 if n.IsZero() {
515 return d.null(out)
516 }
517 fallthrough
518 default:
519 failf("cannot decode node with unknown kind %d", n.Kind)
520 }
521 return good
522}
523
524func (d *decoder) document(n *Node, out reflect.Value) (good bool) {
525 if len(n.Content) == 1 {

Callers 10

documentMethod · 0.95
aliasMethod · 0.95
sequenceMethod · 0.95
mappingMethod · 0.95
mappingStructMethod · 0.95
mergeMethod · 0.95
DecodeMethod · 0.80
DecodeMethod · 0.80
unmarshalFunction · 0.80

Calls 10

documentMethod · 0.95
aliasMethod · 0.95
prepareMethod · 0.95
scalarMethod · 0.95
mappingMethod · 0.95
sequenceMethod · 0.95
nullMethod · 0.95
allowedAliasRatioFunction · 0.85
failfFunction · 0.85
IsZeroMethod · 0.65

Tested by

no test coverage detected