doc.dev1x.org

golangci-lint

1. golangci-lintとは

2. インストール

# binary will be $(go env GOPATH)/bin/golangci-lint
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2

># or install it into ./bin/
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.55.2

# In alpine linux (as it does not come with curl by default)
wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.55.2

golangci-lint --version

IMPORTANT: It's highly recommended installing a specific version of golangci-lint available on the releases page.

3. 使い方

golangci-lint run
golangci-lint run dir1 dir2/... dir3/file1.go
golangci-lint run --fix
golangci-lint run --dissable-all -E errorcheck

4. 設定ファイル

5. 開発ツールとの統合

VS Code

各種CIツール

参考資料

Appendix-1 その他雑多な情報

golangci-lintに含まれるlinter