astutils

package
v0.30.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2024 License: MPL-2.0 Imports: 7 Imported by: 72

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompositeLitContainsAnyField

func CompositeLitContainsAnyField(cl *ast.CompositeLit, fieldNames ...string) bool

func CompositeLitField

func CompositeLitField(cl *ast.CompositeLit, fieldName string) *ast.KeyValueExpr

func CompositeLitFieldBoolValue

func CompositeLitFieldBoolValue(cl *ast.CompositeLit, fieldName string) *bool

func CompositeLitFieldExprValue

func CompositeLitFieldExprValue(cl *ast.CompositeLit, fieldName string) *ast.Expr

func CompositeLitFieldIntValue

func CompositeLitFieldIntValue(cl *ast.CompositeLit, fieldName string) *int

func CompositeLitFields

func CompositeLitFields(cl *ast.CompositeLit) map[string]*ast.KeyValueExpr

func ExprBoolValue

func ExprBoolValue(e ast.Expr) *bool

ExprBoolValue fetches a bool value from the Expr If the Expr cannot parse as a bool, returns nil.

func ExprIntValue

func ExprIntValue(e ast.Expr) *int

ExprIntValue fetches an int value from the Expr If the Expr cannot parse as an int, returns nil.

func ExprStringValue

func ExprStringValue(e ast.Expr) *string

ExprStringValue fetches a string value from the Expr If the Expr is not BasicLit, returns an empty string.

func ExprValue

func ExprValue(e ast.Expr) *ast.Expr

ExprValue fetches a pointer to the Expr If the Expr is nil, returns nil

func FieldListName

func FieldListName(fieldList *ast.FieldList, fieldPosition int, namePosition int) *string

FieldListName returns field name at field position and name position if found

func FieldListNames

func FieldListNames(fieldList *ast.FieldList, position int) []*ast.Ident

FieldListNames returns field names at field position if found

func FieldListType

func FieldListType(fieldList *ast.FieldList, position int) *ast.Expr

FieldListType returns type at field position if found

func FuncTypeFromNode

func FuncTypeFromNode(node ast.Node) *ast.FuncType

func HasFieldListLength added in v0.13.0

func HasFieldListLength(fieldList *ast.FieldList, expectedLength int) bool

HasFieldListLength returns true if the FieldList has the expected length If FieldList is nil, checks against expected length of 0.

func IsExprTypeArrayError added in v0.12.0

func IsExprTypeArrayError(e ast.Expr) bool

IsExprTypeArrayError returns true if the expression matches []error

func IsExprTypeArrayString added in v0.12.0

func IsExprTypeArrayString(e ast.Expr) bool

IsExprTypeArrayString returns true if the expression matches []string

func IsExprTypeBool added in v0.13.0

func IsExprTypeBool(e ast.Expr) bool

IsExprTypeString returns true if the expression matches bool

func IsExprTypeError added in v0.12.0

func IsExprTypeError(e ast.Expr) bool

IsExprTypeError returns true if the expression matches string

func IsExprTypeInterface added in v0.12.0

func IsExprTypeInterface(e ast.Expr) bool

IsExprTypeInterface returns true if the expression matches interface{}

func IsExprTypeMapStringInterface added in v0.13.0

func IsExprTypeMapStringInterface(e ast.Expr) bool

IsExprTypeMapStringInterface returns true if the expression matches []string

func IsExprTypeString added in v0.12.0

func IsExprTypeString(e ast.Expr) bool

IsExprTypeString returns true if the expression matches string

func IsFieldListType

func IsFieldListType(fieldList *ast.FieldList, position int, exprFunc func(ast.Expr) bool) bool

IsFieldListType returns true if the field at position is present and matches expected ast.Expr

func IsFieldListTypeModulePackageType added in v0.15.0

func IsFieldListTypeModulePackageType(fieldList *ast.FieldList, position int, info *types.Info, module string, packageSuffix string, typeName string) bool

IsFieldListTypeModulePackageType returns true if the field at position is present and matches expected module and package type

This function automatically handles Go module versioning in import paths. To explicitly check an import path, use IsFieldListTypePackageType instead.

func IsFieldListTypePackageType

func IsFieldListTypePackageType(fieldList *ast.FieldList, position int, info *types.Info, packageSuffix string, typeName string) bool

IsFieldListTypePackageType returns true if the field at position is present and matches expected package type

This function checks an explicit import path. To allow any Go module version in the import path, use IsFieldListTypeModulePackageType instead.

func IsModulePackageFunc added in v0.15.0

func IsModulePackageFunc(e ast.Expr, info *types.Info, module string, packageSuffix string, funcName string) bool

IsModulePackageFunc returns true if the function package suffix (for vendoring) and name matches

This function automatically handles Go module versioning in import paths. To explicitly check an import path, use IsPackageFunc instead.

func IsModulePackageFunctionFieldListType added in v0.15.0

func IsModulePackageFunctionFieldListType(e ast.Expr, info *types.Info, module string, packageSuffix string, typeName string) bool

IsModulePackageFunctionFieldListType returns true if the function parameter package suffix (for vendoring) and name matches

This function automatically handles Go module versioning in import paths. To explicitly check an import path, use IsPackageFunctionFieldListType instead.

func IsModulePackageNamedType added in v0.15.0

func IsModulePackageNamedType(t *types.Named, module string, packageSuffix string, typeName string) bool

IsModulePackageNamedType returns if the type name matches and is from the package suffix

This function automatically handles Go module versioning in import paths. To explicitly check an import path, use IsPackageNamedType instead.

func IsModulePackageReceiverMethod added in v0.15.0

func IsModulePackageReceiverMethod(e ast.Expr, info *types.Info, module string, packageSuffix string, receiverName string, methodName string) bool

IsModulePackageReceiverMethod returns true if the module and package suffix (for vendoring), receiver name, and method name match

This function automatically handles Go module versioning in import paths. To explicitly check an import path, use IsPackageReceiverMethod instead.

func IsModulePackageType added in v0.15.0

func IsModulePackageType(t types.Type, module string, packageSuffix string, typeName string) bool

IsModulePackageType returns true if the type name can be matched and is from the package suffix

This function automatically handles Go module versioning in import paths. To explicitly check an import path, use IsPackageType instead.

func IsPackageFunc

func IsPackageFunc(e ast.Expr, info *types.Info, packageSuffix string, funcName string) bool

IsPackageFunc returns true if the function package suffix (for vendoring) and name matches

This function checks an explicit import path. To allow any Go module version in the import path, use IsModulePackageFunc instead.

func IsPackageFunctionFieldListType

func IsPackageFunctionFieldListType(e ast.Expr, info *types.Info, packageSuffix string, typeName string) bool

IsPackageFunctionFieldListType returns true if the function parameter package suffix (for vendoring) and name matches

This function checks an explicit import path. To allow any Go module version in the import path, use IsModuleFunctionFieldListType instead.

func IsPackageNamedType

func IsPackageNamedType(t *types.Named, packageSuffix string, typeName string) bool

IsPackageNamedType returns if the type name matches and is from the package suffix

This function checks an explicit import path. To allow any Go module version in the import path, use IsModulePackageNamedType instead.

func IsPackageReceiverMethod

func IsPackageReceiverMethod(e ast.Expr, info *types.Info, packageSuffix string, receiverName, methodName string) bool

IsPackageReceiverMethod returns true if the package suffix (for vendoring), receiver name, and method name match

This function checks an explicit import path. To allow any Go module version in the import path, use IsModulePackageReceiverMethod instead.

func IsPackageType

func IsPackageType(t types.Type, packageSuffix string, typeName string) bool

IsPackageType returns true if the type name can be matched and is from the package suffix

This function checks an explicit import path. To allow any Go module version in the import path, use IsModulePackageType instead.

func IsStdlibPackageFunc added in v0.17.0

func IsStdlibPackageFunc(e ast.Expr, info *types.Info, packagePath string, funcName string) bool

IsStdlibPackageFunc returns true if the function package suffix (for vendoring) and name matches

This function checks an explicit import path without vendoring. To allow vendored paths, use IsPackageFunc instead.

func IsStdlibPackageFunctionFieldListType added in v0.17.0

func IsStdlibPackageFunctionFieldListType(e ast.Expr, info *types.Info, packagePath string, typeName string) bool

IsStdlibPackageFunctionFieldListType returns true if the function parameter package suffix (for vendoring) and name matches

This function checks an explicit import path without vendoring. To allow vendored paths, use IsPackageFunctionFieldListType instead.

func IsStdlibPackageNamedType added in v0.17.0

func IsStdlibPackageNamedType(t *types.Named, packagePath string, typeName string) bool

IsStdlibPackageNamedType returns if the type name matches and is from the package suffix

This function checks an explicit import path without vendoring. To allow vendored paths, use IsPackageNamedType instead.

func IsStdlibPackageReceiverMethod added in v0.17.0

func IsStdlibPackageReceiverMethod(e ast.Expr, info *types.Info, packagePath string, receiverName, methodName string) bool

IsStdlibPackageReceiverMethod returns true if the package suffix (for vendoring), receiver name, and method name match

This function checks an explicit import path without vendoring. To allow vendored paths, use IsPackageReceiverMethod instead.

func IsStdlibPackageType added in v0.17.0

func IsStdlibPackageType(t types.Type, packagePath string, typeName string) bool

IsStdlibPackageType returns true if the type name can be matched and is from the package suffix

This function checks an explicit import path without vendoring. To allow vendored paths, use IsPackageType instead.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL