Golang go/ast.FuncDecl type example
package go/ast
A FuncDecl node represents a function declaration.
Golang go/ast.FuncDecl type usage example
func getFuncName(funcDecl *ast.FuncDecl) string {
prefix := ""
if funcDecl.Recv != nil {
recvType := funcDecl.Recv.List[0].Type
if recvStarType, ok := recvType.(*ast.StarExpr); ok {
prefix = "(*" + recvStarType.X.(*ast.Ident).Name + ")"
} else {
prefix = recvType.(*ast.Ident).Name
}
prefix += "."
}
return prefix + funcDecl.Name.Name
}
References :
https://github.com/revel/revel/blob/master/harness/reflect.go
Advertisement
Something interesting
Tutorials
+4.9k Unix/Linux : secure copying between servers with SCP command examples
+11.6k Swift : Convert (cast) Float to String
+8.1k Golang : Randomize letters from a string example
+36.4k Golang : Convert date or time stamp from string to time.Time type
+20k Golang : How to run your code only once with sync.Once object
+9.5k Golang : Changing a RGBA image number of channels with OpenCV
+9.4k Golang : Launch Mac OS X Preview (or other OS) application from your program example
+7.8k Golang : Reverse a string with unicode
+5.4k Golang : fmt.Println prints out empty data from struct
+11.3k Golang : Fix fmt.Scanf() on Windows will scan input twice problem
+12.1k Golang : Save webcamera frames to video file
+4.8k Which content-type(MIME type) to use for JSON data