Skip to content

Commit

Permalink
Merge pull request #32 from KompiTech/feature/defaultString
Browse files Browse the repository at this point in the history
GetStringWithDefault
  • Loading branch information
majkowskiPatrik authored Mar 17, 2022
2 parents 796d9a0 + 6e83e38 commit fe568cb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,14 @@ func (r Rmap) GetString(key string) (string, error) {
return valS, nil
}

func (r Rmap) GetStringWithDefault(key, def string) (string, error) {
if r.Exists(key) {
return r.GetString(key)
} else {
return def, nil
}
}

func (r Rmap) MustGetString(key string) string {
val, err := r.GetString(key)
if err != nil {
Expand Down

0 comments on commit fe568cb

Please sign in to comment.