...

Source file src/golang.org/x/tools/go/callgraph/rta/testdata/func.go

Documentation: golang.org/x/tools/go/callgraph/rta/testdata

     1  //go:build ignore
     2  // +build ignore
     3  
     4  package main
     5  
     6  // Test of dynamic function calls.
     7  // No interfaces, so no runtime/reflect types.
     8  
     9  func A1() {
    10  	A2(0)
    11  }
    12  
    13  func A2(int) {} // not address-taken
    14  
    15  func B() {} // unreachable
    16  
    17  var (
    18  	C = func(int) {}
    19  	D = func(int) {}
    20  )
    21  
    22  func main() {
    23  	A1()
    24  
    25  	pfn := C
    26  	pfn(0) // calls C and D but not A2 (same sig but not address-taken)
    27  }
    28  
    29  // WANT:
    30  //
    31  //  edge main --dynamic function call--> init$1
    32  //  edge main --dynamic function call--> init$2
    33  //
    34  //  reachable A1
    35  //  reachable A2
    36  //  reachable init$1
    37  //  reachable init$2
    38  // !reachable B
    39  //  reachable main
    40  

View as plain text