name: Lint

on:
  workflow_call:

permissions:
  contents: read

jobs:
  lint:
    name: Run Linter
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2

      - name: Set up Go
        uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5
        with:
          go-version: "1.24.3"

      - name: Install dependencies
        run: go mod download

      - name: Run golangci-lint
        uses: golangci/golangci-lint-action@481777f62fe06de6923fd3a69efd3ba597fe628a
        with:
          args: --timeout=5m --config= # Use default linter settings

      - name: Format Go code
        run: |
          go fmt ./...

      - name: Check for uncommitted changes after formatting
        run: |
          git diff --exit-code || (echo "Detected unformatted files. Run 'go fmt' to format your code."; exit 1)
