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
+16.3k Golang : Loop each day of the current month example
+7.5k Golang : Get YouTube playlist
+6.9k Golang : Decode XML data from RSS feed
+23.6k Golang : minus time with Time.Add() or Time.AddDate() functions to calculate past date
+13.6k Golang : Set image canvas or background to transparent
+21.6k Golang : GORM create record or insert new record into database example
+9.8k Golang : Get current, epoch time and display by year, month and day
+12.3k Golang : Flush and close file created by os.Create and bufio.NewWriter example
+9.4k Golang : Qt Yes No and Quit message box example
+11.1k Golang : How to determine a prime number?
+21.2k Golang : How to force compile or remove object files first before rebuild?
+19.9k Golang : How to get time from unix nano example