github.com/lemon-mint/libuseful@v1.3.1-0.20220724073654-ee73785d5aa0/example/copystruct/copy.go (about) 1 package main 2 3 import ( 4 "fmt" 5 6 "github.com/lemon-mint/libuseful" 7 ) 8 9 type s1 struct { 10 Exported1 int 11 Exported2 bool 12 13 unExported1 int 14 unExported2 bool 15 } 16 17 func main() { 18 a := s1{ 19 Exported1: 1024, 20 Exported2: true, 21 unExported1: 2048, 22 unExported2: true, 23 } 24 b := s1{} 25 fmt.Println("A:", a) 26 fmt.Println("B:", b) 27 libuseful.CopyStruct(&b, &a) 28 fmt.Println("A:", a) 29 fmt.Println("B:", b) 30 }