Closed AmitKumarDas closed 2 years ago
func fn(m map[int]int) {
m = make(map[int]int)
}
func main() {
var m map[int]int
fn(m)
fmt.Println(m == nil) // true
}
// map is not a reference variable
// map is a pointer to runtime.hmap structure
// a map value is the same size as a uintptr–one machine word
func main() {
var m map[int]int
var p uintptr
fmt.Println(unsafe.Sizeof(m), unsafe.Sizeof(p)) // 8 8 (linux/amd64)
}
// map like channels are pointers to runtime types
// slice is not
refer