I am trying to use golangci-lint in a github actions workflow but get this error:
level=warning msg="[runner] Can't run linter goanalysis_metalinter: buildir: failed to load package : could not load export data: no export data for "go.uber.org/zap/zaptest""
level=error msg="Running error: can't run linter goanalysis_metalinternbuildir: failed to load package : could not load export data: no export data for "go.uber.org/zap/zaptest""
I am using this workflow:
jobs:
lint-golang:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: "0"
- uses: actions/setup-go@v5
with:
go-version: '1.21'
- name: Cache Go modules
uses: actions/cache@v4
with:
path: ${{env.GOPATH}}/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Just
uses: extractions/setup-just@v1
- name: Lint Go Repos
run: just go_lint
Where just go_lint
is:
go_lint:
#!/usr/bin/env bash
set -e
if ! command -v golangci-lint &> /dev/null; then
go install github.com/golangci/golangci-lint/cmd/[email protected]
fi
echo "Linting Chain..."
cd chain && golangci-lint run -c ../.golangci.yaml --path-prefix='chain/'
echo "Linting Relayer..."
cd ../oprelayer && golangci-lint run -c ../.golangci.yaml --path-prefix='oprelayer/'
echo "Linting Prober..."
cd ../prober && golangci-lint run -c ../.golangci.yaml --path-prefix='prober/'
echo "Linting Proof Service..."
cd ../proof_service && golangci-lint run -c ../.golangci.yaml --path-prefix='proof_service/'
cd ..
When ran locally there is no such issue so I think it must be a part of CI. If I use the actual github action instead of the just target and test each sub-directory itself in the workflow the issue persists.
I have tried running go mod tidy
, go mod vendor
and go build
as all the issues online suggest. I have determined the issue to be in the oprelayer
directory and have ran go get -u go.uber.org/zap
and go get -u go.uber.org/zap/zaptest
but the issue persists.