Hi,

let's say you want to find all calls to the specific function 
(strconv.Atoi, for example) using AST. It's kinda easy to do using 
Info.Uses, but how to go from Object in Uses to the whole expression with 
call?

Let's say, we have a code:
package main


import "strconv"


var fn = strconv.Atoi


func foo() func(string) (int, error) {
 return fn
}


var fn2 = foo()


func main() {
 strconv.Atoi("42")
 fn("42")
 fn2("42")
}

And I want to get this output:
 Found Atoi call at: line:10:2: strconv.Atoi("42")
 Found Atoi call at: line:11:2: fn("42")
 Found Atoi call at: line:12:2: fn2("42")

Using 'Info.Uses' only gives two entries - one is where Atoi is explicitly 
called, second, when it's assigned to fn, which is far from what I need.

Here is an example to start: https://play.golang.org/p/fIs3xWYfxk

Any advice?


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to