Skip to content

Commit

Permalink
add Unquote()
Browse files Browse the repository at this point in the history
  • Loading branch information
aine-etke committed Sep 9, 2024
1 parent 7f02297 commit 2f58f46
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"crypto/sha256"
"encoding/hex"
"sort"
"strconv"
"strings"
)

Expand All @@ -28,6 +29,15 @@ func MapKeys[T string, V any](data map[string]V) []string {
return keys
}

// Unquote is a wrapper around strconv.Unquote, but returns original string if unquoting fails
func Unquote(s string) string {
unquoted, err := strconv.Unquote(s)
if err != nil {
return s
}
return unquoted
}

// MergeMapKeys returns map keys only from multiple maps
func MergeMapKeys[V any](m map[string]V, adds ...map[string]V) []string {
uniq := map[string]bool{}
Expand Down

0 comments on commit 2f58f46

Please sign in to comment.