Last active
September 11, 2020 04:40
-
-
Save csthompson/eae418eb29c573220b45fd00eeb9a934 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"go/ast" | |
"go/parser" | |
"go/token" | |
) | |
func main() { | |
//Create a FileSet to work with | |
fset := token.NewFileSet() | |
//Parse the file and create an AST | |
file, err := parser.ParseFile(fset, "../nats_publisher/main.go", nil, parser.ParseComments) | |
if err != nil { | |
panic(err) | |
} | |
ast.Inspect(file, func(n ast.Node) bool { | |
// Find Function Call Statements | |
funcCall, ok := n.(*ast.CallExpr) | |
if ok { | |
fmt.Println(funcCall.Fun) | |
} | |
return true | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment