...
1
2
3
4
5
6
7 package main
8
9 import (
10 "fmt"
11 "os"
12 )
13
14 var is []func() int
15
16 func inline(j, k int) []*int {
17 var a []*int
18 for private := j; private < k; private++ {
19 a = append(a, &private)
20 }
21 return a
22 }
23
24
25 func notinline(j, k int) ([]*int, *int) {
26 for shared := j; shared < k; shared++ {
27 if shared == k/2 {
28
29
30
31 return inline(j, k), &shared
32 }
33 }
34 return nil, &j
35 }
36
37 func main() {
38 a, p := notinline(2, 9)
39 fmt.Printf("a[0]=%d,*p=%d\n", *a[0], *p)
40 if *a[0] != 2 {
41 os.Exit(1)
42 }
43 }
44
View as plain text