repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.6.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-yaml
      - id: check-added-large-files
        args: ["--maxkb=512"]
      - id: check-merge-conflict
      - id: mixed-line-ending
        args: ["--fix=lf"]

  # Go-specific hooks. Local hooks (rather than third-party repos) so
  # the version of each tool tracks whatever is on the developer's
  # PATH, matching what they'd use to run the same checks by hand.
  # Required tools:
  #   * go            (toolchain matching go.mod)
  #   * gofumpt       — `go install mvdan.cc/gofumpt@latest`
  #   * golangci-lint — `go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6`
  #
  # Install + activate the hooks once per clone:
  #   pre-commit install
  - repo: local
    hooks:
      - id: gofumpt
        name: gofumpt
        description: Format Go files with gofumpt (stricter superset of gofmt)
        entry: bash -c 'PATH="$(go env GOPATH)/bin:$PATH" exec gofumpt -l -w "$@"' --
        language: system
        types: [go]
        pass_filenames: true

      - id: go-vet
        name: go vet
        description: Run go vet across all packages
        entry: go vet ./...
        language: system
        types: [go]
        pass_filenames: false

      - id: golangci-lint
        name: golangci-lint
        description: Run golangci-lint against the whole module (matches CI)
        entry: bash -c 'PATH="$(go env GOPATH)/bin:$PATH" exec golangci-lint run ./...'
        language: system
        types: [go]
        pass_filenames: false
