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