github.com/inturn/pre-commit-gobuild@v1.0.12/hooks/go-errcheck/README.md (about)

     1  # errcheck
     2  
     3  errcheck is a program for checking for unchecked errors in go programs.
     4  
     5  ## Use
     6  
     7  For basic usage, just give the package path of interest as the first argument.
     8  
     9  To check all packages beneath the current directory:
    10  
    11      errcheck ./...
    12  
    13  Or check all packages in your $GOPATH and $GOROOT:
    14  
    15      errcheck all
    16  
    17  errcheck also recognizes the following command-line options:
    18  
    19  The `-tags` flag takes a space-separated list of build tags, just like `go
    20  build`. If you are using any custom build tags in your code base, you may need
    21  to specify the relevant tags here.
    22  
    23  The `-asserts` flag enables checking for ignored type assertion results. It
    24  takes no arguments.
    25  
    26  The `-blank` flag enables checking for assignments of errors to the
    27  blank identifier. It takes no arguments.
    28  
    29  
    30  ## Excluding functions
    31  
    32  Use the `-exclude` flag to specify a path to a file containing a list of functions to
    33  be excluded.
    34  
    35      errcheck -exclude errcheck_excludes.txt path/to/package
    36  
    37  The file should contain one function signature per line. The format for function signatures is
    38  `package.FunctionName` while for methods it's `(package.Receiver).MethodName` for value receivers
    39  and `(*package.Receiver).MethodName` for pointer receivers.
    40  
    41  An example of an exclude file is:
    42  
    43      io/ioutil.ReadFile
    44      (*net/http.Client).Do
    45  
    46  The exclude list is combined with an internal list for functions in the Go standard library that
    47  have an error return type but are documented to never return an error.
    48  
    49  ## Cgo
    50  
    51  Currently errcheck is unable to check packages that import "C" due to limitations in the importer when used with versions earlier than Go 1.11.
    52  
    53  However, you can use errcheck on packages that depend on those which use cgo. In order for this to work you need to go install the cgo dependencies before running errcheck on the dependent packages.
    54  
    55  See https://github.com/kisielk/errcheck/issues/16 for more details.
    56  
    57  ## Exit Codes
    58  
    59  errcheck returns 1 if any problems were found in the checked files.
    60  It returns 2 if there were any other failures.