47 lines
696 B
Go
47 lines
696 B
Go
package dict
|
|
|
|
func Copy(dest *Dict, src Dict) {
|
|
if *dest == nil {
|
|
*dest = make(Dict)
|
|
}
|
|
for k, v := range src {
|
|
if vv, ok := v.(Dict); ok {
|
|
t := make(Dict)
|
|
Copy(&t, vv)
|
|
(*dest)[k] = t
|
|
} else {
|
|
(*dest)[k] = v
|
|
}
|
|
}
|
|
}
|
|
|
|
func (dest *Dict) CopyFrom(src Dict) {
|
|
if *dest == nil {
|
|
*dest = make(Dict)
|
|
}
|
|
for k, v := range src {
|
|
if vv, ok := v.(Dict); ok {
|
|
t := make(Dict)
|
|
t.CopyFrom(vv)
|
|
(*dest)[k] = t
|
|
} else {
|
|
(*dest)[k] = v
|
|
}
|
|
}
|
|
}
|
|
|
|
func (src Dict) CopyTo(dest *Dict) {
|
|
if *dest == nil {
|
|
*dest = make(Dict)
|
|
}
|
|
for k, v := range src {
|
|
if vv, ok := v.(Dict); ok {
|
|
t := make(Dict)
|
|
vv.CopyTo(&t)
|
|
(*dest)[k] = t
|
|
} else {
|
|
(*dest)[k] = v
|
|
}
|
|
}
|
|
}
|