Documentation ¶
Overview ¶
Package lint provides the foundation for tools like gosimple.
Index ¶
- func ExportedType(typ types.Type) bool
- func ExprToInt(expr ast.Expr) (string, bool)
- func IsBlank(id ast.Expr) bool
- func IsIdent(expr ast.Expr, ident string) bool
- func IsNil(expr ast.Expr) bool
- func IsOne(expr ast.Expr) bool
- func IsPkgDot(expr ast.Expr, pkg, name string) bool
- func IsZero(expr ast.Expr) bool
- func ReceiverType(fn *ast.FuncDecl) string
- func SrcLine(src []byte, p token.Position) string
- type ByPosition
- type Category
- type File
- func (f *File) BoolConst(expr ast.Expr) bool
- func (f *File) Errorf(n ast.Node, confidence float64, args ...interface{}) *Problem
- func (f *File) FirstLineOf(node, match ast.Node) string
- func (f *File) IndentOf(node ast.Node) string
- func (f *File) IsBoolConst(expr ast.Expr) bool
- func (f *File) IsMain() bool
- func (f *File) IsTest() bool
- func (f *File) IsUntypedConst(expr ast.Expr) (defType string, ok bool)
- func (f *File) Render(x interface{}) string
- func (f *File) RenderArgs(args []ast.Expr) string
- func (f *File) SrcLineWithMatch(node ast.Node, pattern string) (m []string)
- func (f *File) Walk(fn func(ast.Node) bool)
- type Func
- type Link
- type Linter
- type Pkg
- type Problem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExportedType ¶
exportedType reports whether typ is an exported type. It is imprecise, and will err on the side of returning true, such as for composite types.
func IsBlank ¶
isBlank returns whether id is the blank identifier "_". If id == nil, the answer is false.
func ReceiverType ¶
Types ¶
type ByPosition ¶
type ByPosition []Problem
func (ByPosition) Len ¶
func (p ByPosition) Len() int
func (ByPosition) Less ¶
func (p ByPosition) Less(i, j int) bool
func (ByPosition) Swap ¶
func (p ByPosition) Swap(i, j int)
type File ¶
file represents a file being linted.
func (*File) Errorf ¶
The variadic arguments may start with link and category types, and must end with a format string and any arguments. It returns the new Problem.
func (*File) FirstLineOf ¶
firstLineOf renders the given node and returns its first line. It will also match the indentation of another node.
func (*File) IsUntypedConst ¶
isUntypedConst reports whether expr is an untyped constant, and indicates what its default type is. scope may be nil.
func (*File) SrcLineWithMatch ¶
type Linter ¶
type Linter struct {
Funcs []Func
}
A Linter lints Go source code.
type Pkg ¶
type Pkg struct { TypesPkg *types.Package TypesInfo *types.Info // contains filtered or unexported fields }
pkg represents a package being linted.
type Problem ¶
type Problem struct { Position token.Position // position in source file Text string // the prose that describes the problem Link string // (optional) the link to the style guide for the problem Confidence float64 // a value in (0,1] estimating the confidence in this problem's correctness LineText string // the source line Category string // a short name for the general category of the problem // If the problem has a suggested fix (the minority case), // ReplacementLine is a full replacement for the relevant line of the source file. ReplacementLine string }
Problem represents a problem in some source code.