Linting Workflow¶
The lint.yml workflow provides comprehensive code quality analysis using golangci-lint v2.
Usage¶
Enabled Linters¶
The default configuration enables 50+ linters:
Bug Detection¶
| Linter | Description |
|---|---|
errcheck | Unchecked error returns |
staticcheck | Comprehensive static analysis |
govet | Go vet checks |
bodyclose | HTTP response body closure |
nilerr | Nil error returns |
sqlclosecheck | SQL resource cleanup |
Complexity¶
| Linter | Threshold | Description |
|---|---|---|
gocyclo | 15 | Cyclomatic complexity |
gocognit | 20 | Cognitive complexity |
funlen | 100 lines | Function length |
nestif | 5 | Nested if depth |
Code Style¶
| Linter | Description |
|---|---|
gofmt | Standard formatting |
gofumpt | Strict formatting |
goimports | Import management |
revive | Style enforcement |
misspell | Spelling errors |
Security¶
| Linter | Description |
|---|---|
gosec | Security vulnerabilities |
ineffassign | Ineffectual assignments |
Inputs¶
| Input | Type | Default | Description |
|---|---|---|---|
go-version | string | '1.24' | Go version |
go-version-file | string | '' | Path to go.mod |
working-directory | string | '.' | Code directory |
golangci-lint-version | string | 'latest' | Linter version |
config-path | string | '' | Custom config path |
args | string | '' | Additional arguments |
only-new-issues | boolean | false | New issues only |
Examples¶
PR Optimization¶
Only report new issues on pull requests:
jobs:
lint:
uses: go-gamma/actions/.github/workflows/lint.yml@v1
with:
go-version: '1.24'
only-new-issues: ${{ github.event_name == 'pull_request' }}
Custom Configuration¶
Use your project's .golangci.yml:
jobs:
lint:
uses: go-gamma/actions/.github/workflows/lint.yml@v1
with:
go-version: '1.24'
config-path: '.golangci.yml'
Additional Arguments¶
jobs:
lint:
uses: go-gamma/actions/.github/workflows/lint.yml@v1
with:
go-version: '1.24'
args: '--fix' # Auto-fix issues
Custom Configuration¶
Create .golangci.yml in your project to override defaults:
version: "2"
linters:
enable:
- gocyclo
- gosec
linters-settings:
gocyclo:
min-complexity: 20 # Override default of 15
issues:
exclude-rules:
- path: _test\.go
linters:
- errcheck
See the golangci-lint Configuration for the complete default config.