Run lint on golang repo in travis

521 views Asked by At

I run locally on my project the following command

gometalinter --config=gometalinter.json ./...

at the beginning I got some errors and I was fixed them all!

now I run the same command exaclty in Travis script and I got vendor errros like

vendor/github.com/spf13/viper/flags.go:3:8:warning: error return value not checked (could not import github.com/spf13/pflag (go/build: importGo github.com/spf13/pflag: exit status 1) (errcheck)
vendor/github.com/spf13/viper/viper.go:42:7:warning: error return value not checked (could not import github.com/pelletier/go-toml (go/build: importGo github.com/pelletier/go-toml: exit status 1) (errcheck)

This is the gometalinter.json for the config

{
  "vendor": true,
  "Deadline": "2m",
  "Sort": [
    "linter",
    "severity"
  ],
  "DisableAll": true,
  "Enable": [
    "gotypex",
    "vetshadow",
    "errcheck",
    "gocyclo",
    "vet",
    "golint",
    "vetshadow",
    "ineffassign",


  ],
  "Cyclo": 10,
  "LineLength": 120
}

I dont understand why locally I dont get this error (i've the vendor repo) and why it ask for vendor error ? what could be the reason ?

2

There are 2 answers

1
poy On

gometalinter runs binaries in your path to do its check. I have had problems where my CI would have one set of binaries versions while my local development environment would have different versions.

Try updating all the required binaries on your local machine.

2
Dmitry Harnitski On

Try --vendor flag and check versions of gometalinter and all used linters.

Extract from gometalinter documentation:

How do I make gometalinter work with Go 1.5 vendoring?

gometalinter has a --vendor flag that just sets GO15VENDOREXPERIMENT=1, however the underlying tools must support it. Ensure that all of the linters are up to date and built with Go 1.5 (gometalinter --install --force) then run gometalinter --vendor .. That should be it.