I switched my project from dep to Go modules. In a build stage on Travis CI, I run golangci-lint and receive the following error message:
$ golangci-lint run -v
level=info msg="[config_reader] Config search paths: [./ /home/travis/gopath/src/github.com/bmuschko/link-verifier /home/travis/gopath/src/github.com/bmuschko /home/travis/gopath/src/github.com /home/travis/gopath/src /home/travis/gopath /home/travis /home /]"
level=info msg="Gocritic enabled checks: [appendAssign assignOp caseOrder dupArg dupBranchBody dupCase flagDeref ifElseChain regexpMust singleCaseSwitch sloppyLen switchTrue typeSwitchVar underef unlambda unslice defaultCaseOrder]"
level=info msg="[lintersdb] Active 8 linters: [deadcode errcheck govet ineffassign megacheck structcheck typecheck varcheck]"
level=info msg="[loader] Go packages loading at mode load deps types and syntax took 1.739936991s"
level=error msg="Running error: context loading failed: failed to load program with go/packages: go [list -e -json -compiled -test=true -export=false -deps=true -- ./...]: exit status 1: go: github.com/spf13/[email protected]: git init --bare in /home/travis/gopath/pkg/mod/cache/vcs/389cbbf79b0218a16e6f902e349b1cabca23e0203c06f228d24031e72b6cf480: exit status 128:\n\tfatal: cannot copy '/usr/share/git-core/templates/hooks/pre-push.sample' to '/home/travis/gopath/pkg/mod/cache/vcs/389cbbf79b0218a16e6f902e349b1cabca23e0203c06f228d24031e72b6cf480/hooks/pre-push.sample': File exists\ngo: finding github.com/stretchr/testify v1.3.0\ngo: finding github.com/inconshreveable/mousetrap v1.0.0\ngo: github.com/spf13/[email protected]: git remote add origin https://github.com/spf13/cobra in /home/travis/gopath/pkg/mod/cache/vcs/3acf82b7c983ee417907a837a4ec1200962dbab34a15385a11bc6f255dc04d6e: exit status 128:\n\tfatal: remote origin already exists.\ngo: github.com/stretchr/[email protected]: unknown revision v1.3.0\ngo: github.com/davecgh/[email protected]: git remote add origin https://github.com/davecgh/go-spew in /home/travis/gopath/pkg/mod/cache/vcs/b9a4b9bbdb4a59723f2348415ad7ffda91568455a1cfd92e97976132bdfbaf57: exit status 128:\n\tfatal: remote origin already exists.\ngo: github.com/inconshreveable/[email protected]: unknown revision v1.0.0\ngo: finding mvdan.cc/xurls/v2 v2.0.0\ngo: error loading module requirements\n"
level=info msg="Memory: 18 samples, avg is 68.4MB, max is 68.4MB"
level=info msg="Execution took 1.781875182s"
The command "golangci-lint run -v" exited with 3.
Do you know why this might fail? Here's one of the failing builds.
Please include the following information:
I was using build stages in Travis CI. Travis does not carry over already downloaded modules so you'll have to run go mod download before running golangci-lint.
Most helpful comment
I was using build stages in Travis CI. Travis does not carry over already downloaded modules so you'll have to run
go mod downloadbefore runninggolangci-lint.