Skip to content

Commit

Permalink
Merge pull request #28 from projectdiscovery/runtime-map-delete-key
Browse files Browse the repository at this point in the history
Adding delete key helper for runtime map
  • Loading branch information
Mzack9999 authored Oct 7, 2021
2 parents 7a8cfa6 + dd9c32b commit 6acd354
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions runtime_map.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package goflags

import (
"errors"
"fmt"
"strings"

Expand Down Expand Up @@ -44,6 +45,15 @@ func (runtimeMap *RuntimeMap) Set(value string) error {
return nil
}

// Del removes the specified key
func (runtimeMap *RuntimeMap) Del(key string) error {
if runtimeMap.kv == nil {
return errors.New("empty runtime map")
}
delete(runtimeMap.kv, key)
return nil
}

// IsEmpty specifies if the underlying map is empty
func (runtimeMap *RuntimeMap) IsEmpty() bool {
return runtimeMap.kv == nil || len(runtimeMap.kv) == 0
Expand Down

0 comments on commit 6acd354

Please sign in to comment.