golang指针内容复制
在go语言中比如一个指定内容复制到另外一个指针的内容中,这个与C/C++相同非常简单,不需要多做解释。
下面看例子
package main import "fmt" type Student struct { Name string } func main() { var s *Student = new(Student) var t *Student =new(Student) s.Name = "jack" *t = *s fmt.Println("t=",t , "s=" ,s) s.Name = "rose" fmt.Println("t=",t , "s=" , s) }
控制台输出
t= &{jack} s= &{jack} t= &{jack} s= &{rose} Process finished with exit code 0