Skip to content

Commit 7ac4ce8

Browse files
committed
Added Dump method
1 parent 3856e7b commit 7ac4ce8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

properties.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ import (
6969
"reflect"
7070
"regexp"
7171
"runtime"
72+
"sort"
7273
"strings"
7374
)
7475

@@ -297,3 +298,18 @@ func DeleteUnexpandedPropsFromString(str string) string {
297298
rxp := regexp.MustCompile("\\{.+?\\}")
298299
return rxp.ReplaceAllString(str, "")
299300
}
301+
302+
// Dump returns a representation of the map in golang source format
303+
func (m Map) Dump() string {
304+
res := "properties.Map{\n"
305+
keys := []string{}
306+
for k := range m {
307+
keys = append(keys, k)
308+
}
309+
sort.Strings(keys)
310+
for _, k := range keys {
311+
res += fmt.Sprintf(" \"%s\": \"%s\",\n", strings.Replace(k, `"`, `\"`, -1), strings.Replace(m[k], `"`, `\"`, -1))
312+
}
313+
res += "}"
314+
return res
315+
}

0 commit comments

Comments
 (0)