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