MCPcopy
hub / github.com/pelletier/go-toml / setAnyKey

Method setAnyKey

unmarshaler.go:561–576  ·  view source on GitHub ↗

setAnyKey assigns the value of a key-value into the native map m, following the (possibly dotted) key and creating intermediate maps as needed.

(m map[string]interface{}, key unstable.Iterator, value *unstable.Node)

Source from the content-addressed store, hash-verified

559// setAnyKey assigns the value of a key-value into the native map m, following
560// the (possibly dotted) key and creating intermediate maps as needed.
561func (d *decoder) setAnyKey(m map[string]interface{}, key unstable.Iterator, value *unstable.Node) error {
562 cur := m
563 for key.Next() {
564 name := d.intern(key.Node().Data)
565 if key.IsLast() {
566 av, err := d.decodeAny(value)
567 if err != nil {
568 return err
569 }
570 cur[name] = av
571 return nil
572 }
573 cur = d.anyChildTable(cur, name)
574 }
575 return nil
576}
577
578// anyChildTable returns the child table at name within cur, creating it if
579// absent and descending into the current (last) element when an array table

Callers 1

decodeAnyMethod · 0.95

Calls 6

internMethod · 0.95
decodeAnyMethod · 0.95
anyChildTableMethod · 0.95
NodeMethod · 0.80
IsLastMethod · 0.80
NextMethod · 0.45

Tested by

no test coverage detected