github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/pkg/domain/utils/utils.go (about) 1 package utils 2 3 import ( 4 "net/url" 5 "strings" 6 7 jsoniter "github.com/json-iterator/go" 8 ) 9 10 var json = jsoniter.ConfigCompatibleWithStandardLibrary 11 12 // DeepCopy does a deep copy of a structure 13 // Error checking of parameters delegated to json engine 14 var DeepCopy = func(dst interface{}, src interface{}) error { 15 payload, err := json.Marshal(src) 16 if err != nil { 17 return err 18 } 19 20 err = json.Unmarshal(payload, dst) 21 if err != nil { 22 return err 23 } 24 return nil 25 } 26 27 func ToLibpodFilters(f url.Values) (filters []string) { 28 for k, v := range f { 29 filters = append(filters, k+"="+v[0]) 30 } 31 return 32 } 33 34 func ToURLValues(f []string) (filters url.Values) { 35 filters = make(url.Values) 36 for _, v := range f { 37 t := strings.SplitN(v, "=", 2) 38 filters.Add(t[0], t[1]) 39 } 40 return 41 }