0

I am working on a code static analysis, and I have a challenge now. For example I have two go source file.

a.go

package test1
func Func1() {
    test2.Func2()
    fmt.println("func1")
}

b.go

package test2
func Func2() {
    fmt.println("func2")
}

How to check if func1 ast node has invoke relation with func2 ast node in Golang?

lwp007
  • 25
  • 5
  • 1
    You may want to look at [this](https://github.com/dominikh/go-tools/tree/master/staticcheck) – ifnotak Mar 18 '19 at 10:58
  • 1
    And seems like [that answer](https://stackoverflow.com/a/41630530/6426898) will help you – Iveronanomi Mar 18 '19 at 11:02
  • Maybe I did not describe my question clearly, I just want to check the invoke relationship statically. I noticed that the discussion above focus mainly on runtime reflection. – lwp007 Mar 18 '19 at 13:12
  • 1
    It's not really relevant to the question but your sample code is invalid. `test1` cannot call `test2.func2` because it is not exported. – Adrian Mar 18 '19 at 14:16

0 Answers0