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:

    -asmdecl
       enable asmdecl analysis
    -assign
       enable assign analysis
    -atomic
       enable atomic analysis
    -bools
       enable bools analysis
    -buildtag
       enable buildtag analysis
    -cgocall
       enable cgocall analysis
    -composites
       enable composites analysis
    -composites.whitelist
       use composite white list; for testing only (default true)
    -copylocks
       enable copylocks analysis
    -errorsas
       enable errorsas analysis
    -httpresponse
       enable httpresponse analysis
    -loopclosure
       enable loopclosure analysis
    -lostcancel
       enable lostcancel analysis
    -nilfunc
       enable nilfunc analysis
    -printf
       enable printf analysis
    -printf.funcs value
       comma-separated list of print function names to check (default (*log.Logger).Fatal,(*log.Logger).Fatalf,(*log.Logger).Fatalln,(*log.Logger).Panic,(*log.Logger).Panicf,(*log.Logger).Panicln,(*log.Logger).Print,(*log.Logger).Printf,(*log.Logger).Println,(*testing.common).Error,(*testing.common).Errorf,(*testing.common).Fatal,(*testing.common).Fatalf,(*testing.common).Log,(*testing.common).Logf,(*testing.common).Skip,(*testing.common).Skipf,(testing.TB).Error,(testing.TB).Errorf,(testing.TB).Fatal,(testing.TB).Fatalf,(testing.TB).Log,(testing.TB).Logf,(testing.TB).Skip,(testing.TB).Skipf,fmt.Errorf,fmt.Fprint,fmt.Fprintf,fmt.Fprintln,fmt.Print,fmt.Printf,fmt.Println,fmt.Sprint,fmt.Sprintf,fmt.Sprintln,log.Fatal,log.Fatalf,log.Fatalln,log.Panic,log.Panicf,log.Panicln,log.Print,log.Printf,log.Println,runtime/trace.Logf)
    -shift
       enable shift analysis
    -stdmethods
       enable stdmethods analysis
    -structtag
       enable structtag analysis
    -tags string
       space-separated list of build tags to apply when parsing
    -tests
       enable tests analysis
    -unmarshal
       enable unmarshal analysis
    -unreachable
       enable unreachable analysis
    -unsafeptr
       enable unsafeptr analysis
    -unusedresult
       enable unusedresult analysis
    -unusedresult.funcs value
       comma-separated list of functions whose results must be used (default errors.New,fmt.Errorf,fmt.Sprint,fmt.Sprintf,sort.Reverse)
    -unusedresult.stringmethods value
       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.

  • 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.

  • experimental:

    No tool specific experimental options are available.

YAML Examples

  • With default options:

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

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

    inspecode:
      tools:
        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 ""