name: 'staticcheck'
on:
  pull_request:
    paths: ['**.go', 'go.mod', '.github/workflows/*']
  push:
    branches: ['main', 'aix']

jobs:
  staticcheck:
    name:    'staticcheck'
    runs-on: 'ubuntu-latest'
    steps:
      - uses: 'actions/setup-go@v5'
        with:
          go-version: '1.23'

      - uses: 'actions/cache@v4'
        with:
          key: '${{ runner.os }}-staticcheck'
          path: |
            ${{ runner.temp }}/staticcheck
            ${{ steps.install_go.outputs.GOCACHE || '' }}

      - run: |
          export STATICCHECK_CACHE="${{ runner.temp }}/staticcheck"
          go install honnef.co/go/tools/cmd/staticcheck@latest

          $(go env GOPATH)/bin/staticcheck -matrix <<EOF
          windows: GOOS=windows
          linux: GOOS=linux
          freebsd: GOOS=freebsd
          openbsd: GOOS=openbsd
          netbsd: GOOS=netbsd
          darwin: GOOS=darwin
          illumos: GOOS=illumos
          EOF
