1
2
3
4
5 package main
6
7 import (
8 "./p"
9 "fmt"
10 )
11
12 type I interface {
13 Add(out *P)
14 }
15
16 type P struct {
17 V *int32
18 }
19
20 type T struct{}
21
22 var x int32 = 42
23
24 func Int32x(i int32) *int32 {
25 return &i
26 }
27
28 func (T) Add(out *P) {
29 out.V = p.Int32(x)
30 }
31
32 var PP P
33 var out *P = &PP
34
35 func F(s I) interface{} {
36 s.Add(out)
37 return out
38 }
39
40 var s T
41
42 func main() {
43 println("Starting")
44 fmt.Sprint(new(int32))
45 resp := F(s).(*P)
46 println("Before, *resp.V=", *resp.V)
47 println("After, *resp.V=", *resp.V)
48 if got, want := *resp.V, int32(42); got != want {
49 fmt.Printf("FAIL, got %v, want %v", got, want)
50 }
51 }
52
View as plain text