name: 'Setup Go Environment'
description: 'Setup Go with caching and common environment variables'
inputs:
  go-version-file:
    description: 'Path to go.mod file'
    required: false
    default: 'go.mod'
outputs:
  go-version:
    description: 'The Go version that was installed'
    value: ${{ steps.setup-go.outputs.go-version }}
  cache-hit:
    description: 'Whether the Go cache was hit'
    value: ${{ steps.setup-go.outputs.cache-hit }}
runs:
  using: 'composite'
  steps:
    - name: Setup Go
      id: setup-go
      uses: actions/setup-go@v5
      with:
        go-version-file: ${{ inputs.go-version-file }}
        cache: true

    - name: Set Go environment variables
      shell: bash
      run: |
        echo "GOMAXPROCS=2" >> $GITHUB_ENV
        echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV
        echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_ENV

    - name: Print Go environment
      shell: bash
      run: |
        echo "Go version: $(go version)"
        echo "GOOS: $(go env GOOS)"
        echo "GOARCH: $(go env GOARCH)"
        echo "Cache directory: $(go env GOCACHE)"
        echo "Module cache: $(go env GOMODCACHE)"
