This repository has been archived on 2021-09-07. You can view files and clone it, but cannot push or open issues or pull requests.
2018-11-26 17:43:45 +08:00

25 lines
310 B
Go

package main
import "fmt"
// 示例结构体
type Example struct {
Content string
}
func (e *Example) Clone() *Example {
res := *e
return &res
}
func main() {
r1 := new(Example)
r1.Content = "this is example 1"
r2 := r1.Clone()
r2.Content = "this is example 2"
fmt.Println(r1)
fmt.Println(r2)
}