I believe the Recv field does what you want? On Saturday, September 18, 2021 at 8:20:19 PM UTC+2 tjgur...@gmail.com wrote:
> Hi, > > I was working on a tool for internal use where I had to work with the go's > abstract syntax tree specially with the FuncDecls. I wanted to filter the > ast to only function declarations without methods. I was wondering if there > is a way to distinguish between normal functions and structure methods. I'm > sure there must be a way since the godoc distinguishes them but don't know > if they had to implement it in a certain way. > > Currently my code uses AST's inspect function and traverses the tree. > Example, > > ```Go > ast.Inspect(syntaxtTree, func(n *ast.Node) bool { > ... > switch x := n.(type) { > case *ast.FuncDecl: > ... > } > ``` > > If anyone knows a way to distinguish these, please do let me know. Thanks! > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/1b52e479-ab40-4859-ace0-604baf9b355bn%40googlegroups.com.