Go语言 之结构体指针变量
package main import ( "fmt" ) type Student struct { id int name string } //结构体传值是值传递 func InitData(s *Student) { s.id = 1 s.name = "yang" } func main() { var s Student InitData(&s) fmt.Println(s) }
package main import ( "fmt" ) type Student struct { id int name string } //结构体传值是值传递 func InitData(s *Student) { s.id = 1 s.name = "yang" } func main() { var s Student InitData(&s) fmt.Println(s) }