在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
func deepCopyJSON(src map[string]interface{}, dest map[string]interface{}) error { if src == nil { return errors.New("src is nil. You cannot read from a nil map") } if dest == nil { return errors.New("dest is nil. You cannot insert to a nil map") } jsonStr, err := json.Marshal(src) if err != nil { return err } err = json.Unmarshal(jsonStr, &dest) if err != nil { return err } return nil }
------------------------ To copy a map content need to execute a for loop and fetch the index value 1 by 1 with element and assign it to another map. Below is a short example.
C:\golang\codes>go run example.go
x => 1 y => 2 C:\golang\codes> |
请发表评论