# Same gates as CI job go (subset): gofmt, vet, golangci-lint. $ErrorActionPreference = 'Stop' Set-Location (Join-Path $PSScriptRoot '..') # Enumerate packages in this module instead of recursively formatting unrelated # checkouts such as .claude/worktrees. Include tagged tests in each package dir. $packageDirs = @(go list -f '{{.Dir}}' ./...) if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } $unfmt = @( foreach ($packageDir in ($packageDirs | Sort-Object -Unique)) { $sourceFiles = @(Get-ChildItem -LiteralPath $packageDir -File -Filter '*.go' | Select-Object -ExpandProperty FullName) if ($sourceFiles.Count -gt 0) { gofmt -l @sourceFiles if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } } } ) if ($unfmt) { Write-Error "gofmt: unformatted files:`n$unfmt" } go vet ./... if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } $golangci = Get-Command golangci-lint -ErrorAction SilentlyContinue if (-not $golangci) { $golangciPath = Join-Path $env:USERPROFILE 'go\bin\golangci-lint.exe' if (Test-Path $golangciPath) { $golangci = @{ Source = $golangciPath } } } if ($golangci) { & $golangci.Source run if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } } else { Write-Warning 'lint-go: golangci-lint not found, skipping (CI will run it)' }