Running error: context loading failed: failed to load program with go/packages: could not determine GOARCH and Go compiler
See original GitHub issueHi, 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"```
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:24 (8 by maintainers)
Top Results From Across the Web
ERRO Running error: context loading failed: failed to ... - GitHub
My program uses modules, so the vendor solution would not apply. I'm first running go generate to get around any compile errors, then...
Read more >failed to load program with go/packages: could not determine ...
Running error : context loading failed: failed to load program with go/packages: could not determine GOARCH and Go compiler.
Read more >Golang linter issues 'context loading failed: no go files to ...
in our project for linting our Golang code. Until now, what we did is running this bash script (from the root directory of...
Read more >runtime - Go Packages
The GOTRACEBACK variable controls the amount of output generated when a Go program fails due to an unrecovered panic or an unexpected runtime...
Read more >Go 1.18 Release Notes - The Go Programming Language
We expect almost all Go programs to continue to compile and run as before. ... Before Go 1.18, the compiler did not report...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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)?