我正在使用GitHub操作https://github.com/golangci/golangci-lint-action
我得到了错误:
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/go-critic@v0.6.1/checkers/checkers.go:58 +0x4b4
Error: golangci-lint exit with code 2
Ran golangci-lint in 13383ms
这是使用golang v1.18.0 https://github.com/golangci/golangci-lint/issues/2374的golangci-lint
的已知问题
我的GitHub操作文件是:
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
我也试过用途:
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
但是两个都失败了,那我该怎么办?
我在项目中打开了这个问题,以防它对https://github.com/golangci/golangci-lint-action/issues/442有帮助。
5条答案
按热度按时间iklwldmw1#
将golangci/golangci-lint-action、actions/setup-go和actions/checkout转换到v3对我来说很有用。
g6ll5ycj2#
Issue 442由PR 275和commit 6ee1db2(v1.4.1)修复,基于注解:
矩阵键似乎不匹配,纠正它可以解决问题吗?
Charlie Revett在第2374期中提到的当前解决方法是:
golangci-lint
find / -type d -name go 2> /dev/null
执行一些目录清理find / -type d -name "golangci-lint" 2> /dev/null
执行一些目录清理.pkg
)通过go.dev/dl
安装go1.17.11.darwin-arm64.pkg
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.46.2
(current latest version)安装golangci-lint
。请参阅“从源代码安装”
qlzsbp2j3#
在我的MacOS上,我简单地删除了所有以前的版本,并通过以下命令安装了最新的版本
5n0oy7gb4#
我在这里也看到了同样的问题,并且发现在
golangci-lint
中使用go 1.19工具链时会出现这个问题。如果我用go 1.18运行它,它工作得很好。用go 1.19,它失败了,错误和这里给出的一样。
cl25kdpy5#
我的案子有点棘手。
我从
brew install
和go get
安装了golangci-lint
。(这就是为什么brew install golangci-lint
或brew upgrade golangci-lint
对我不起作用...)所以我先运行
which golangci-lint
看看哪个不工作,然后按照这里的其他答案升级或重新安装它。