Source file
test/abi/double_nested_addressed_struct.go
1
2
3
4
5
6
7
8
9
10
11
12
13 package main
14
15 import (
16 "fmt"
17 )
18
19 var sink *string
20
21 type stringPair struct {
22 a, b string
23 }
24
25 type stringPairPair struct {
26 x, y stringPair
27 }
28
29
30
31
32
33
34
35 func H(spp stringPairPair) string {
36 F(&spp)
37 return spp.x.a + " " + spp.x.b + " " + spp.y.a + " " + spp.y.b
38 }
39
40
41
42 func G(d, c, b, a string) stringPairPair {
43 return stringPairPair{stringPair{a, b}, stringPair{c, d}}
44 }
45
46
47
48 func F(spp *stringPairPair) {
49 spp.x.a, spp.x.b, spp.y.a, spp.y.b = spp.y.b, spp.y.a, spp.x.b, spp.x.a
50 }
51
52 func main() {
53 spp := G("this", "is", "a", "test")
54 s := H(spp)
55 gotVsWant(s, "this is a test")
56 }
57
58 func gotVsWant(got, want string) {
59 if got != want {
60 fmt.Printf("FAIL, got %s, wanted %s\n", got, want)
61 }
62 }
63
View as plain text