/
utils.go
executable file
·49 lines (41 loc) · 928 Bytes
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package controller
import (
"strings"
"github.com/go-xmlfmt/xmlfmt"
)
func compareConf(srcConf, dstConf map[string]string) bool {
if len(srcConf) != len(dstConf) {
return false
}
for key, valueSrc := range srcConf {
valueDst, ok := dstConf[key]
if !ok || valueSrc != valueDst {
return false
}
}
return true
}
func map2String(kv map[string]string) string {
var sb strings.Builder
for key, value := range kv {
sb.WriteString(key)
sb.WriteString("=")
sb.WriteString(value)
sb.WriteString("\n")
}
return sb.String()
}
func map2Xml(properties map[string]string) string {
var res string = `<configuration>`
for key, value := range properties {
property := `<property>
<name>` + key + `</name>
<value>` + value + `</value>
</property>`
res = res + property
}
res = res + `</configuration>`
res = xmlfmt.FormatXML(res, "", " ")
return res
}
func int32Ptr(i int32) *int32 { return &i }