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
+5.6k Javascript : How to refresh page with JQuery ?
+9.2k Golang : Generate Codabar
+13.9k Golang : convert(cast) string to float value
+8.8k Golang : On lambda, anonymous, inline functions and function literals
+6.8k Golang : Join lines with certain suffix symbol example
+9.1k Golang : Intercept and compare HTTP response code example
+5.6k Golang : Configure crontab to poll every two minutes 8am to 6pm Monday to Friday
+6.6k Golang : Warp text string by number of characters or runes example
+21.1k Golang : For loop continue,break and range
+14k Golang : concatenate(combine) strings
+8.2k How to show different content from website server when AdBlock is detected?
+22.9k Golang : Test file read write permission example