Documentation ¶
Overview ¶
Package checkers provides utilities for implementing lint checkers.
Index ¶
- Variables
- func Error(errs ...string) error
- func FindBin(bin string) (string, error)
- func GoFiles(pkgs ...string) ([]string, error)
- func InstallMissing(bin, getPath, importPath string) (string, error)
- func Lint(bin, getPath, installPath string, pkgs []string, args ...string) error
- func SkipDirs(fns ...func(path, name string) bool) func(string, string) bool
- func SkipTestdata(path, name string) bool
- func SkipUnderscoreDirs(path, name string) bool
- func SkipVendor(path, name string) bool
- func Unload(pkg string)
- type ExecErrors
- type ExecResult
- type Package
Constants ¶
This section is empty.
Variables ¶
var SkipDirFunc = SkipDirs(SkipUnderscoreDirs, SkipTestdata)
SkipDirFunc determines if a directory must be skipped when listing packages. It takes two arguments, the full path and name of the directory and returns true if the directory should be skipped.
Functions ¶
func Error ¶
Error returns an error containing errs.
If errs is empty, nil is returned. If not the returned error will implement the following interface
type errors interface { Errors() []string }
and return errs unmodified.
func FindBin ¶
FindBin returns bin if it exists in the path. If not it checks go bin directories ($GOROOT/bin and $GOPATH/bin) and returns that if it exists. If neither exist it returns an error.
func InstallMissing ¶
InstallMissing runs go get getPath and then go get importPath if bin cannot be found in the directories contained in the PATH environment variable. It returns the path to the installed binary on success.
func Lint ¶
Lint runs the linter specified by bin for each package in pkgs. The linter is installed if necessary using
go get getPath go install installPath
If getPath is empty, installPath is used for go get.
func SkipTestdata ¶
SkipTestdata skips all testdata directories
func SkipUnderscoreDirs ¶
SkipUnderscoreDirs skips all directories with the _ prefix
Types ¶
type ExecErrors ¶
type ExecErrors []string
ExecErrors holds errors collected from executing a linter
func (*ExecErrors) Add ¶
func (e *ExecErrors) Add(r ExecResult)
Add appends any output from stdout or stderr as an error. The exit code is ignored. Empty lines are also ignored
type ExecResult ¶
ExecResult holds a status code, stdout and stderr for a single command execution.
type Package ¶
type Package struct { // The path of the package. Can be a wildcard path such as ... Path string // Files holds all files in the package. If the Path is a wildcard path // (...) files in sub packages are also returned. Files []string // All files in Files with a .go extension GoFiles []string // All sub packages if Path is a wildcard, or just Path if not. Pkgs []string // build.Package instance for this package Build *build.Package }
Package holds file and sub directory information about a single package.