package code
import "honnef.co/go/tools/code"
Package code answers structural and type questions about Go code.
Index ¶
- func BoolConst(pass *analysis.Pass, expr ast.Expr) bool
- func CallName(call *ir.CallCommon) string
- func CallNameAST(pass *analysis.Pass, call *ast.CallExpr) string
- func Dereference(T types.Type) types.Type
- func DereferenceR(T types.Type) types.Type
- func ExprToInt(pass *analysis.Pass, expr ast.Expr) (int64, bool)
- func ExprToString(pass *analysis.Pass, expr ast.Expr) (string, bool)
- func File(pass *analysis.Pass, node Positioner) *ast.File
- func FilterDebug(instr []ir.Instruction) []ir.Instruction
- func Generator(pass *analysis.Pass, pos token.Pos) (facts.Generator, bool)
- func GroupSpecs(fset *token.FileSet, specs []ast.Spec) [][]ast.Spec
- func IsBlank(id ast.Expr) bool
- func IsBoolConst(pass *analysis.Pass, expr ast.Expr) bool
- func IsCallTo(call *ir.CallCommon, name string) bool
- func IsCallToAST(pass *analysis.Pass, node ast.Node, name string) bool
- func IsCallToAny(call *ir.CallCommon, names ...string) bool
- func IsCallToAnyAST(pass *analysis.Pass, node ast.Node, names ...string) bool
- func IsExample(fn *ir.Function) bool
- func IsGenerated(pass *analysis.Pass, pos token.Pos) bool
- func IsGoVersion(pass *analysis.Pass, minor int) bool
- func IsIdent(expr ast.Expr, ident string) bool
- func IsInTest(pass *analysis.Pass, node Positioner) bool
- func IsIntLiteral(expr ast.Expr, literal string) bool
- func IsMain(pass *analysis.Pass) bool
- func IsMainLike(pass *analysis.Pass) bool
- func IsNil(pass *analysis.Pass, expr ast.Expr) bool
- func IsObject(obj types.Object, name string) bool
- func IsOfType(pass *analysis.Pass, expr ast.Expr, name string) bool
- func IsPointerLike(T types.Type) bool
- func IsType(T types.Type, name string) bool
- func IsZero(expr ast.Expr) bool
- func MayHaveSideEffects(pass *analysis.Pass, expr ast.Expr, purity facts.PurityResult) bool
- func Preamble(f *ast.File) string
- func Preorder(pass *analysis.Pass, fn func(ast.Node), types ...ast.Node)
- func SelectorName(pass *analysis.Pass, expr *ast.SelectorExpr) string
- type Field
- type Positioner
Functions ¶
func BoolConst ¶
func CallName ¶
func CallName(call *ir.CallCommon) string
func CallNameAST ¶
func Dereference ¶
Dereference returns a pointer's element type; otherwise it returns T.
func DereferenceR ¶
DereferenceR returns a pointer's element type; otherwise it returns T. If the element type is itself a pointer, DereferenceR will be applied recursively.
func ExprToInt ¶
func ExprToString ¶
func File ¶
func File(pass *analysis.Pass, node Positioner) *ast.File
func FilterDebug ¶
func FilterDebug(instr []ir.Instruction) []ir.Instruction
func Generator ¶
Generator returns the generator that generated the file containing pos. It ignores //line directives.
func GroupSpecs ¶
func IsBlank ¶
isBlank returns whether id is the blank identifier "_". If id == nil, the answer is false.
func IsBoolConst ¶
func IsCallTo ¶
func IsCallTo(call *ir.CallCommon, name string) bool
func IsCallToAST ¶
func IsCallToAny ¶
func IsCallToAny(call *ir.CallCommon, names ...string) bool
func IsCallToAnyAST ¶
func IsExample ¶
func IsGenerated ¶
IsGenerated reports whether pos is in a generated file, It ignores //line directives.
func IsGoVersion ¶
func IsIdent ¶
func IsInTest ¶
func IsInTest(pass *analysis.Pass, node Positioner) bool
func IsIntLiteral ¶
func IsMain ¶
IsMain reports whether the package being processed is a package main.
func IsMainLike ¶
IsMainLike reports whether the package being processed is a main-like package. A main-like package is a package that is package main, or that is intended to be used by a tool framework such as cobra to implement a command.
Note that this function errs on the side of false positives; it may return true for packages that aren't main-like. IsMainLike is intended for analyses that wish to suppress diagnostics for main-like packages to avoid false positives.
func IsNil ¶
func IsObject ¶
func IsOfType ¶
func IsPointerLike ¶
func IsType ¶
func IsZero ¶
Deprecated: use IsIntLiteral instead
func MayHaveSideEffects ¶
MayHaveSideEffects reports whether expr may have side effects. If the purity argument is nil, this function implements a purely syntactic check, meaning that any function call may have side effects, regardless of the called function's body. Otherwise, purity will be consulted to determine the purity of function calls.
func Preamble ¶
func Preorder ¶
func SelectorName ¶
func SelectorName(pass *analysis.Pass, expr *ast.SelectorExpr) string
Types ¶
type Field ¶
func FlattenFields ¶
FlattenFields recursively flattens T and embedded structs, returning a list of fields. If multiple fields with the same name exist, all will be returned.
type Positioner ¶
Source Files ¶
code.go
- Version
- v0.0.1-2020.1.5
- Published
- Jul 30, 2020
- Platform
- js/wasm
- Imports
- 15 packages
- Last checked
- 1 minute ago –
Tools for package owners.