Skip to content

Commit a94c46e

Browse files
committed
[common] Add Del method to gera.StringWrapMap
1 parent 108c508 commit a94c46e

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

common/gera/stringmap.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type StringMap interface {
4040

4141
Get(key string) (string, bool)
4242
Set(key string, value string) bool
43+
Del(key string) bool
4344

4445
Flattened() (map[string]string, error)
4546
FlattenedParent() (map[string]string, error)
@@ -186,6 +187,16 @@ func (w *StringWrapMap) Set(key string, value string) (ok bool) {
186187
return true
187188
}
188189

190+
func (w *StringWrapMap) Del(key string) (ok bool) {
191+
if w == nil || w.theMap == nil {
192+
return false
193+
}
194+
if _, exists := w.theMap[key]; exists {
195+
delete(w.theMap, key)
196+
}
197+
return true
198+
}
199+
189200
func (w *StringWrapMap) Has(key string) bool {
190201
_, ok := w.Get(key)
191202
return ok

0 commit comments

Comments
 (0)