In modern collaborative development, automated code review is a key factor in improving team efficiency. Ideally, we want a linter like golangci-lint to run automatically when a Pull Request is created and provide direct feedback in GitHub PR comments. This is exactly what reviewdog is made for.
This article explains how to combine golangci-lint with reviewdog using GitHub Actions.
π§° Tool Overview
- golangci-lint: An all-in-one linting tool for Go that supports many linters (like
govet,errcheck, etc.). - reviewdog: A tool that supports various linters and posts the results as comments in GitHub PRs.
π¦ Quick Start
1. Create .github/workflows/lint.yml
name: Lint with golangci-lint and reviewdog
on: [pull_request]
jobs:
golangci-lint:
name: π§ͺ Lint Go Code
runs-on: ubuntu-latest
steps:
- name: π₯ Checkout code
uses: actions/checkout@v4
- name: π§ Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
- name: π§Ή Run golangci-lint with reviewdog
uses: reviewdog/action-golangci-lint@v2
with:
github_token: $
golangci_lint_flags: '--timeout=3m'
reporter: github-pr-review # Alternatives: github-pr-check / github-check
level: warning
π― Result Preview
In your PR, reviewdog will automatically annotate lint issues directly on the code lines, like this:

π Configuration Options
| Parameter | Description |
|---|---|
github_token |
GitHub token, usually secrets.GITHUB_TOKEN. |
reporter |
Output type: github-pr-review (inline), github-pr-check, github-check |
level |
Severity level: info, warning, error |
golangci_lint_flags |
Flags passed to golangci-lint, such as config files or filtering rules. |
π Project Structure Example
.
βββ .github/
β βββ workflows/
β βββ lint.yml # reviewdog integration
βββ .golangci.yml # golangci-lint config
βββ main.go
βββ go.mod
Sample .golangci.yml
run:
timeout: 3m
linters:
enable:
- govet
- errcheck
- staticcheck
- unused
issues:
exclude-rules:
- path: _test\.go
linters:
- errcheck
β Tips
reviewdog/action-golangci-lintautomatically installsgolangci-lint, no manual setup required.reporter: github-pr-reviewis ideal for inline annotations during code review.- Works with private repos as long as
secrets.GITHUB_TOKENis configured.
π§© Further Reading
π§ Conclusion
By integrating golangci-lint with reviewdog in your GitHub PR workflow, you can provide developers with immediate feedback on code style and potential bugs, ultimately improving code quality and team collaboration.