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
+28.5k Golang : Change a file last modified date and time
+9.4k Golang : Find the length of big.Int variable example
+13.6k Golang : Set image canvas or background to transparent
+20.3k Swift : Convert (cast) Int to int32 or Uint32
+7.8k Swift : Convert (cast) String to Double
+7.7k Golang : Test if an input is an Armstrong number example
+25.7k Golang : How to write CSV data to file
+23.1k Golang : Randomly pick an item from a slice/array example
+6k Golang : Function as an argument type example
+9.9k Golang : Ordinal and Ordinalize a given number to the English ordinal numeral
+31.5k Golang : Example for ECDSA(Elliptic Curve Digital Signature Algorithm) package functions
+6.4k PHP : Proper way to get UTF-8 character or string length