当你声明一个map的时候: m := make(map[int]int) 编译器会调用 runtime.makemap: // makemap implements a Go map creation make(map[k]v, hint) // If the compiler has determined that the map or the first bucket // can be created on the stack, h and/or bucket may be non-nil…
1. 结构体做函数的参数或返回值时,都会被重新拷贝一份如果不想拷贝,可以传递结构体指针 package main import "fmt" type Person struct { name string age int } var p = Person{"武沛齐", 18} func doSomething() Person { // 结构体做函数的参数或返回值时,都会被重新拷贝一份,如果不想拷贝,可以传递结构体指针 return p } func main()…