首页 > 解决方案 > 如何修复 GitHub Actions 中的 golangci-lint 错误?

问题描述

我收到了这个错误:

Run actions-contrib/golangci-lint@v1
/usr/bin/docker run --name cc495678c14da19ea04d82b4276bf15086b4bc_b162c0 --label cc4956 --workdir /github/workspace --rm -e GOROOT -e INPUT_GOLANGCI_LINT_VERSION -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/foo/foo":"/github/workspace" cc4956:78c14da19ea04d82b4276bf15086b4bc
level=warning msg="Failed to discover go env: failed to run 'go env': exit status 2"
level=error msg="Running error: context loading failed: failed to load program with go/packages: could not parse GOARCH and Go compiler in format \"<GOARCH> <compiler>\" from stdout of go command:\nGOROOT=/opt/hostedtoolcache/go/1.15.6/x64 GOPATH=/go GO111MODULE= *** go [list -f {{context.GOARCH}} {{context.Compiler}} -- unsafe]\ndir: /github/workspace\nstdout: <<>>\nstderr: <<go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.15.6/x64\n>>"

添加时

    - name: Run golangci-lint
    - uses: actions/checkout@v2
    - name: Run golangci-lint
      uses: actions-contrib/golangci-lint@v1

go.yml.

标签: dockergogithub-actions

解决方案


推荐阅读