Source file
test/inline_literal.go
1
2
3
4
5
6
7 package main
8
9 import (
10 "log"
11 "reflect"
12 "runtime"
13 )
14
15 func hello() string {
16 return "Hello World"
17 }
18
19 func foo() string {
20 x := hello()
21 y := hello()
22 return x + y
23 }
24
25 func bar() string {
26 x := hello()
27 return x
28 }
29
30
31 func funcPC(f interface{}) uintptr {
32 return reflect.ValueOf(f).Pointer()
33 }
34
35
36 func main() {
37 pc := funcPC(foo)
38 f := runtime.FuncForPC(pc)
39 for ; runtime.FuncForPC(pc) == f; pc++ {
40 file, line := f.FileLine(pc)
41 if line == 0 {
42 continue
43 }
44
45
46 if line != 16 && !(line >= 19 && line <= 22) {
47 log.Fatalf("unexpected line at PC=%d: %s:%d\n", pc, file, line)
48 }
49 }
50 }
51
View as plain text