Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error using golang 1.18 #442

Closed
rodoufu opened this issue Apr 5, 2022 · 3 comments
Closed

Error using golang 1.18 #442

rodoufu opened this issue Apr 5, 2022 · 3 comments
Labels
question Further information is requested upstream related the golangci-lint but not to the action

Comments

@rodoufu
Copy link

rodoufu commented Apr 5, 2022

I'm getting the error:

Installed golangci-lint into /home/runner/golangci-lint-1.43.0-linux-amd64/golangci-lint in 458ms
Prepared env in 606ms

run golangci-lint
  Running [/home/runner/golangci-lint-1.43.0-linux-amd64/golangci-lint run --out-format=github-actions] in [] ...
  panic: load embedded ruleguard rules: rules/rules.go:13: can't load fmt
  
  goroutine 1 [running]:
  github.com/go-critic/go-critic/checkers.init.9()
  	github.com/go-critic/[email protected]/checkers/checkers.go:58 +0x4b4
  
  Error: golangci-lint exit with code 2
  Ran golangci-lint in 13383ms

Which is a known issue for golangci-lint with golang v1.18.0 golangci/golangci-lint#2374

My GitHub action file is:

name: golangci-lint
on:
  push:
    tags:
      - v*
    branches:
      - master
      - main
  pull_request:
permissions:
  contents: read
jobs:
  golangci:
    name: lint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/setup-go@v2
      - uses: actions/checkout@v2
      - name: golangci-lint
        uses: golangci/golangci-lint-action@v2
        with:
          version: v1.43

I've also tried to use:

name: golangci-lint
on:
  push:
    tags:
      - v*
    branches:
      - master
      - main
  pull_request:
permissions:
  contents: read
jobs:
  golangci:
    strategy:
      matrix:
        go-version: [1.17.x]
    name: lint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/setup-go@v3
        with:
          go-version: ${{ matrix.go }}
      - uses: actions/checkout@v3
      - name: golangci-lint
        uses: golangci/golangci-lint-action@v2
        with:
          version: v1.43

But both are failing, what can I do in that case?

@SVilgelm
Copy link
Member

SVilgelm commented Apr 8, 2022

v2 of the action is used to install the lates stable Go automatically, to skip the installation of go and use the pre installed we had to use skip-go-installation parameter.
But recently we released v3 of the action, it does not install go and uses only pre-installed go.
in you case change uses: golangci/golangci-lint-action@v2 to uses: golangci/golangci-lint-action@v3 in second example

@3100
Copy link
Contributor

3100 commented Apr 15, 2022

The matrix keys do not seem to match, would correcting that solve the problem?

    strategy:
      matrix:
        go-version: [1.17.x]
    name: lint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/setup-go@v3
        with:
          go-version: ${{ matrix.go-version }}

gabriel-vasile added a commit to gabriel-vasile/mimetype that referenced this issue Apr 17, 2022
gabriel-vasile added a commit to gabriel-vasile/mimetype that referenced this issue Apr 17, 2022
@rhcarvalho
Copy link

I ran into a similar problem trying to update a repo to use Go 1.19 and golangci-lint v1.47.3, the latest versions as of writing.

The latest released binary of golangci-lint was built with Go 1.18 and doesn't work with Go 1.19. This action always downloads released binaries.

Workaround

I worked around the issue by building golangci-lint from source using the same Go version that I'm targeting.

Example: https://gist.github.com/rhcarvalho/9f2ae0742f5496271526b3e572da1d34

# .github/workflows/test.yml
# ...
jobs:
  # ...
  lint-go:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-go@v3
        with:
          # go-version: 1.19
          go-version-file: go.mod
          # The builtin cache feature ensures that installing golangci-lint
          # is consistently fast.
          cache: true
          cache-dependency-path: go.sum
      - name: Install golangci-lint
        # Install golangci-lint from source instead of using
        # golangci-lint-action to ensure the golangci-lint binary is built with
        # the same Go version we're targeting.
        # Avoids incompatibility issues such as:
        # - https://github.com/golangci/golangci-lint/issues/2922
        # - https://github.com/golangci/golangci-lint/issues/2673
        # - https://github.com/golangci/golangci-lint-action/issues/442
        run: go install github.com/golangci/golangci-lint/cmd/[email protected]
      - name: Run golangci-lint
        run: golangci-lint run --version --verbose --out-format=github-actions

I hope the above can help others ❤️

SuperSandro2000 added a commit to sapcc/go-makefile-maker that referenced this issue Aug 3, 2022
This reverts commit 7a5a75f.

golangci-lint needs to be build with go 1.19
see golangci/golangci-lint-action#442 (comment)
@ldez ldez closed this as completed Aug 7, 2022
arturmon pushed a commit to arturmon/s3MediaStreamer that referenced this issue Aug 22, 2022
maruina added a commit to maruina/go-infrabin that referenced this issue Sep 13, 2022
@ldez ldez added question Further information is requested upstream related the golangci-lint but not to the action labels Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested upstream related the golangci-lint but not to the action
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants