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