# golangci-lint

golangci-lint is a fast Go linters aggregator that runs 50+ linters in parallel.

## Installation

```bash
# Binary (recommended)
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin

# Go install
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest

# Homebrew (macOS)
brew install golangci-lint
```

## Basic Usage

```bash
# Run all enabled linters
golangci-lint run

# Run on specific directories
golangci-lint run ./pkg/... ./internal/...

# Run specific linters only
golangci-lint run --enable=gofmt,govet,errcheck

# Show all available linters
golangci-lint linters

# Auto-fix issues (when supported)
golangci-lint run --fix
```

## Configuration (.golangci.yml)

```yaml
linters:
  enable:
    - gofmt        # Format checker
    - govet        # Go vet checks
    - errcheck     # Unchecked errors
    - staticcheck  # Static analysis
    - gosimple     # Simplification suggestions
    - ineffassign  # Ineffectual assignments
    - unused       # Unused code
    - misspell     # Spelling mistakes
    - gosec        # Security issues
    - gocyclo      # Cyclomatic complexity

linters-settings:
  gocyclo:
    min-complexity: 15
  govet:
    enable-all: true
  errcheck:
    check-type-assertions: true

issues:
  exclude-rules:
    - path: _test\.go
      linters:
        - errcheck
        - gosec

run:
  timeout: 5m
  tests: true
```

## Popular Linters

| Linter | Purpose |
|--------|---------|
| `errcheck` | Check for unchecked errors |
| `govet` | Official Go vet checks |
| `staticcheck` | Comprehensive static analysis |
| `gosec` | Security vulnerability scanner |
| `gofmt` | Format checker |
| `goimports` | Import organization |
| `misspell` | Spelling mistakes in comments |
| `ineffassign` | Ineffectual assignments |
| `gocyclo` | Cyclomatic complexity |
| `dupl` | Code duplication detector |

## CI Integration

```yaml
# GitHub Actions
- name: golangci-lint
  uses: golangci/golangci-lint-action@v4
  with:
    version: latest
```
