go tool vet

Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string.

Version

Go Versions

Runtime

Go Versions

Supported Languages

Go

Official Documentation

https://golang.org/cmd/vet/

YAML Configuration

go-vet:

  • input:

    Patterns to include in execution and reports.

    Note: Inspecode runs go tool vet for each Go package directory and go tool vet processes all files in the directory recursively. The input patterns are used for selecting the directories containing input files. Therefore, the files excluded by the patterns are processed if they are contained in Go packages that also contain input files, and you may even see logs related to the excluded files in the job console. However, Inspecode eventually ignores any issues detected on the excluded files when generating job reports.

  • ignore:

    Patterns to exclude from execution and reports.

    Note: Just like input:, the ignore patterns may not be applied completely when running go tool vet.

  • auto-fix:

    N/A

  • config-file:

    N/A

  • machine:

    • cpu:

      Amount of CPU. The default machine has 0.25 CPU with 960 MiB RAM.

  • options:

    Below is the list of options that are supported:

    -all
            enable all non-experimental checks
    -asmdecl
            check assembly against Go declarations
    -assign
            check for useless assignments
    -atomic
            check for common mistaken usages of the sync/atomic package
    -bool
            check for mistakes involving boolean operators
    -buildtags
            check that +build tags are valid
    -cgocall
            check for types that may not be passed to cgo calls
    -composites
            check that composite literals used field-keyed elements
    -compositewhitelist
            use composite white list; for testing only (default true)
    -copylocks
            check that locks are not passed by value
    -httpresponse
            check errors are checked before using an http Response
    -lostcancel
            check for failure to call cancelation function returned by context.WithCancel
    -methods
            check that canonically named methods are canonically defined
    -nilfunc
            check for comparisons between functions and nil
    -printf
            check printf-like invocations
    -printfuncs string
            comma-separated list of print function names to check
    -rangeloops
            check that range loop variables are used correctly
    -shift
            check for useless shifts
    -tags string
            space-separated list of build tags to apply when parsing
    -tests
            check for common mistaken usages of tests/documentation examples
    -unreachable
            check for unreachable code
    -unsafeptr
            check for misuse of unsafe.Pointer
    -unusedfuncs string
            comma-separated list of functions whose results must be used (default "errors.New,fmt.Errorf,fmt.Sprintf,fmt.Sprint,sort.Reverse")
    -unusedresult
            check for unused result of calls to functions in -unusedfuncs list and methods in -unusedstringmethods list
    -unusedstringmethods string
            comma-separated list of names of methods of type func() string whose results must be used (default "Error,String")
    
  • thresholds:

    • num-issues:

      No tool specific severity levels are available.

  • experimental:

    • incremental:

      N/A

      Note: The incremental analysis cannot be supported for go tool vet. This is because go tool vet requires buildable packages to work and the results on unchanged files can be affected by changed files.

YAML Examples

  • With default options:

    inspecode:
      go-vet: default
    
  • With custom machine:

    inspecode:
      go-vet:
        machine:
          cpu: 1.5 # 1.5 CPU, 5760 MiB RAM
    
  • With custom options:

    inspecode:
      go-vet:
        options: [-printf, -shadow]
    

Resolving Dependencies

go vet requires all build dependencies to run, so Inspecode resolves the dependencies in the same manner as the go test's case. See the go test page for the details.

results matching ""

    No results matching ""