-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathrw2.go.txt
51 lines (39 loc) · 804 Bytes
/
rw2.go.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"fmt"
"os"
"reflect"
"bytes"
"github.com/glycerine/go-goon"
)
// used in rw2_test.go for round-trip testing write/read
type Dude struct {
Name string
Age int
Addr Address
}
type Address struct {
Street string
Zip string
}
func main() {
rw := Dude{
Name: "Hank",
Age: 33,
Addr: Address{Street: "123 Main Street", Zip: "11111"},
}
var o bytes.Buffer
rw.Save(&o)
rw2 := &Dude{}
rw2.Load(&o)
if !reflect.DeepEqual(&rw, rw2) {
fmt.Printf("rw and rw2 were not equal!\n")
fmt.Printf("\n\n ============= rw: ====\n")
goon.Dump(rw)
fmt.Printf("\n\n ============= rw2: ====\n")
goon.Dump(rw2)
fmt.Printf("\n\n ================\n")
os.Exit(1)
}
fmt.Printf("Load() data matched Saved() data.\n")
}