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
+11.7k Golang : Find age or leap age from date of birth example
+11.8k Golang : GTK Input dialog box examples
+4.1k Javascript : Empty an array example
+12.2k Golang : Detect user location with HTML5 geo-location
+8.8k Yum Error: no such table: packages
+6.8k Golang : Find the longest line of text example
+16.1k Golang : How to check if input from os.Args is integer?
+5.8k Golang : List all packages and search for certain package
+5.6k Golang : Configure crontab to poll every two minutes 8am to 6pm Monday to Friday
+19.5k Golang : Example for DSA(Digital Signature Algorithm) package functions
+20.7k Golang : Saving private and public key to files