gf/.example/container/gmap/gmap_map_clone_safe.go

27 lines
289 B
Go
Raw Normal View History

2019-09-24 23:41:18 +08:00
package main
import (
"github.com/gogf/gf/container/gmap"
"github.com/gogf/gf/frame/g"
)
func main() {
2019-11-30 18:28:11 +08:00
m1 := gmap.New(true)
2019-09-24 23:41:18 +08:00
m1.Set("1", "1")
m2 := m1.Map()
m2["2"] = "2"
g.Dump(m1.Clone())
g.Dump(m2)
//output:
//{
// "1": "1"
//}
//
//{
// "1": "1",
// "2": "2"
//}
}