diff options
author | NeonXP <i@neonxp.dev> | 2022-11-16 21:35:48 +0300 |
---|---|---|
committer | NeonXP <i@neonxp.dev> | 2022-11-16 21:35:48 +0300 |
commit | eb26d597c6d526f84077afdc141b0a5d585c7da3 (patch) | |
tree | a07e5e4c79e3217afb87877287315bb8590b989f /model/map.go | |
parent | c730afe0f889587630789c4fa38267d1edf465f2 (diff) |
Utility methodsv0.0.1
Diffstat (limited to 'model/map.go')
-rw-r--r-- | model/map.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/model/map.go b/model/map.go index 59ba2d8..7bfdaa3 100644 --- a/model/map.go +++ b/model/map.go @@ -41,3 +41,12 @@ func (n *Node) Map(cb func(key string, value *Node) (*Node, error)) error { } return nil } + +// Remove by key from object +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) + return nil +} |