diff options
author | NeonXP <i@neonxp.dev> | 2022-11-21 03:45:23 +0300 |
---|---|---|
committer | NeonXP <i@neonxp.dev> | 2022-11-21 03:45:23 +0300 |
commit | 4934a51c69e1975dc808e094e113b187ebb2c328 (patch) | |
tree | c9944bf5e5a499fb12e0d0f94cc63b12eb747493 /model/map.go | |
parent | 59e421989e5a1b8da5200323c4478645c339d66b (diff) |
Some fixes
Diffstat (limited to 'model/map.go')
-rw-r--r-- | model/map.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/model/map.go b/model/map.go index 7bfdaa3..676288c 100644 --- a/model/map.go +++ b/model/map.go @@ -10,10 +10,10 @@ func (n *Node) Get(key string) (*Node, error) { if n.Type != ObjectNode { return nil, fmt.Errorf("node must be object, got %s", n.Type) } - node, ok := n.objectValue[key] + node, ok := n.ObjectValue[key] if !ok { - keys := make([]string, 0, len(n.objectValue)) - for k := range n.objectValue { + keys := make([]string, 0, len(n.ObjectValue)) + for k := range n.ObjectValue { keys = append(keys, k) } return nil, fmt.Errorf("field '%s' does not exist in object (keys %s)", key, strings.Join(keys, ", ")) @@ -22,22 +22,22 @@ func (n *Node) Get(key string) (*Node, error) { } // Set node to object by key -func (n *Node) Set(key string, value *Node) error { +func (n *Node) Set(key string, value Node) error { if n.Type != ObjectNode { return fmt.Errorf("node must be object, got %s", n.Type) } - n.objectValue[key] = value + n.ObjectValue[key] = &value return nil } // Map callback to each key value pair of object func (n *Node) Map(cb func(key string, value *Node) (*Node, error)) error { - for k, v := range n.objectValue { + for k, v := range n.ObjectValue { newNode, err := cb(k, v) if err != nil { return err } - n.objectValue[k] = newNode + n.ObjectValue[k] = newNode } return nil } @@ -47,6 +47,6 @@ func (n *Node) Remove(key string) error { if n.Type != ObjectNode { return fmt.Errorf("node must be object, got %s", n.Type) } - delete(n.objectValue, key) + delete(n.ObjectValue, key) return nil } |