Source file
test/abi/named_results.go
1
2
3
4
5
6
7
8
9 package main
10
11 import (
12 "fmt"
13 )
14
15 var sink *string
16
17 var y int
18
19
20
21 func F(a, b, c *int) (x int) {
22 x = *a
23 G(&x)
24 x += *b
25 G(&x)
26 x += *c
27 G(&x)
28 return
29 }
30
31
32
33 func G(x *int) {
34 y += *x
35 fmt.Println("y = ", y)
36 }
37
38
39
40 func X() {
41 *sink += " !!!!!!!!!!!!!!!"
42 }
43
44
45
46 func H(s, t string) (result string) {
47 result = "Aloha! " + s + " " + t
48 sink = &result
49 r := ""
50 if len(s) <= len(t) {
51 r = "OKAY! "
52 X()
53 }
54 return r + result
55 }
56
57
58
59 func K(s, t string) (result string) {
60 result = "Aloha! " + s + " " + t
61 r := ""
62 if len(s) <= len(t) {
63 r = "OKAY! "
64 X()
65 }
66 return r + result
67 }
68
69 func main() {
70 a, b, c := 1, 4, 16
71 x := F(&a, &b, &c)
72 fmt.Printf("x = %d\n", x)
73
74 y := H("Hello", "World!")
75 fmt.Println("len(y) =", len(y))
76 fmt.Println("y =", y)
77 z := H("Hello", "Pal!")
78 fmt.Println("len(z) =", len(z))
79 fmt.Println("z =", z)
80
81 fmt.Println()
82
83 y = K("Hello", "World!")
84 fmt.Println("len(y) =", len(y))
85 fmt.Println("y =", y)
86 z = K("Hello", "Pal!")
87 fmt.Println("len(z) =", len(z))
88 fmt.Println("z =", z)
89
90 }
91
View as plain text