blob: c17769f62a9bb8ecdb11729e315b05c1d789da82 (
plain)
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
|
package utils
import (
"net/url"
"strings"
jsoniter "github.com/json-iterator/go"
)
var json = jsoniter.ConfigCompatibleWithStandardLibrary
// DeepCopy does a deep copy of a structure
// Error checking of parameters delegated to json engine
var DeepCopy = func(dst interface{}, src interface{}) error {
payload, err := json.Marshal(src)
if err != nil {
return err
}
err = json.Unmarshal(payload, dst)
if err != nil {
return err
}
return nil
}
func ToLibpodFilters(f url.Values) (filters []string) {
for k, v := range f {
filters = append(filters, k+"="+v[0])
}
return
}
func ToUrlValues(f []string) (filters url.Values) {
filters = make(url.Values)
for _, v := range f {
t := strings.SplitN(v, "=", 2)
filters.Add(t[0], t[1])
}
return
}
|