Documentation
¶
Overview ¶
Package astutils provides utility functions for working with AST nodes
Index ¶
- func FuncSignatureIs(funcDecl *ast.FuncDecl, wantName string, ...) bool
- func GetTypeNames(fields *ast.FieldList) []string
- func GoFmt(x any) string
- func IsCgoExported(f *ast.FuncDecl) bool
- func IsIdent(expr ast.Expr, ident string) bool
- func IsPkgDotName(expr ast.Expr, pkg, name string) bool
- func IsStringLiteral(e ast.Expr) bool
- func NodeHash(node ast.Node) string
- func PickNodes(n ast.Node, selector func(n ast.Node) bool) []ast.Node
- func SeekNode[T ast.Node](n ast.Node, selector func(n ast.Node) bool) T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FuncSignatureIs ¶
func FuncSignatureIs(funcDecl *ast.FuncDecl, wantName string, wantParametersTypes, wantResultsTypes []string) bool
FuncSignatureIs returns true if the given func decl satisfies a signature characterized by the given name, parameters types and return types; false otherwise.
Example: to check if a function declaration has the signature Foo(int, string) (bool,error) call to FuncSignatureIs(funcDecl,"Foo",[]string{"int","string"},[]string{"bool","error"}).
func GetTypeNames ¶ added in v1.10.0
GetTypeNames yields an slice with the string representation of the types of given fields. It yields nil if the field list is nil.
func IsCgoExported ¶ added in v1.10.0
IsCgoExported returns true if the given function declaration is exported as Cgo function, false otherwise.
func IsIdent ¶ added in v1.10.0
IsIdent returns true if the given expression is the identifier with name ident, false otherwise.
func IsPkgDotName ¶ added in v1.10.0
IsPkgDotName returns true if the given expression is a selector expression of the form <pkg>.<name>, false otherwise.
func IsStringLiteral ¶ added in v1.10.0
IsStringLiteral returns true if the given expression is a string literal, false otherwise.
Types ¶
This section is empty.