MCPcopy
hub / github.com/TomWright/dasel / Delete

Method Delete

model/orderedmap/map.go:82–100  ·  view source on GitHub ↗

Delete deletes the value found under the given key.

(key string)

Source from the content-addressed store, hash-verified

80
81// Delete deletes the value found under the given key.
82func (m *Map) Delete(key string) *Map {
83 // Delete the data entry.
84 delete(m.data, key)
85
86 // Remove the item from the keys.
87 foundIndex := -1
88 for i, k := range m.keys {
89 if k == key {
90 foundIndex = i
91 break
92 }
93 }
94
95 if foundIndex >= 0 {
96 m.keys = append((m.keys)[:foundIndex], (m.keys)[foundIndex+1:]...)
97 }
98
99 return m
100}
101
102// KeyValues returns the KeyValue pairs within the map, in the order that they were added.
103func (m *Map) KeyValues() []KeyValue {

Callers 4

TestDeleteFunction · 0.95
TestDeleteNonExistentFunction · 0.95
TestLenFunction · 0.95
DeleteMapKeyMethod · 0.45

Calls

no outgoing calls

Tested by 3

TestDeleteFunction · 0.76
TestDeleteNonExistentFunction · 0.76
TestLenFunction · 0.76