参数和返回值中的指针和值
struct
type MyStruct struct { Val int}func myfunc() MyStruct { return MyStruct{Val: 1}}func myfunc() *MyStruct { return &MyStruct{}}func myfunc(s *MyStruct) { s.Val = 1}
func myfunc() []MyStruct { return []MyStruct{ MyStruct{Val: 1} }}func myfunc() []*MyStruct { return []MyStruct{ &MyStruct{Val: 1} }}func myfunc(s *[]MyStruct) { *s = []MyStruct{ MyStruct{Val: 1} }}func myfunc(s *[]*MyStruct) { *s = []MyStruct{ &MyStruct{Val: 1} }}
慕丝7291255
相关分类