action-golangci-lint: Running error: context loading failed: failed to load program with go/packages: could not determine GOARCH and Go compiler

Hi, I’m trying to use the linter with one of my private github go projects.

on: [pull_request]
jobs:
  golangci-lint:
    name: runner / golangci-lint
    runs-on: ubuntu-latest
    steps:
      - name: Install Go
        uses: actions/setup-go@v1
        with:
          go-version: 1.13
      - name: Check out code into the Go module directory
        uses: actions/checkout@v1
      - name: Configure git for private modules
        env:
          TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
        run: git config --global url."https://MY_USER:${TOKEN}@github.com".insteadOf "https://github.com"
      - name: vendor 
        run: go mod vendor
        env:
          GOPRIVATE: github.com/MYORG/*
      - name: golangci-lint
        uses: reviewdog/action-golangci-lint@v1
        with:
          github_token: ${{ secrets.github_token }}
          golangci_lint_flags: "--config=.golangci.yml -v"

My .golangci.yml file:

run:
  modules-download-mode: vendor

This project uses Go Modules, and references a private repo in Github

the golangci-lint step fails with this error:

level=warning msg="Failed to discover go env: failed to run 'go env': exit status 2"
level=info msg="[lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck]"
level=info msg="[loader] Go packages loading at mode 575 (imports|name|types_sizes|compiled_files|exports_file|files|deps) took 5.496611ms"
level=error msg="Running error: context loading failed: failed to load program with go/packages: could not determine GOARCH and Go compiler"```

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 2
  • Comments: 24 (8 by maintainers)

Commits related to this issue

Most upvoted comments

@haya14busa I tried it on the sample repository for research, the process runs as expected with the old version resulting in an error and the new version with no errors.

Thanks for the fix.

@smutel

My previous GOROOT configuration was wrong, and I misunderstood it as GOPATH. I’m sorry. However, it is still a problem to replace GOROOT, so could you try to change GOROOT to /usr/local/go (not /go)?

Having the same issue