This project uses Go. AI agents must use golangci-lint v2 for all code quality and formatting tasks.
Do not perform any git commits, pushes, or version control actions. Your responsibility ends at preparing the code changes and ensuring they pass all local checks. The human user will handle all commits.
- Initialize:
go mod download - Maintenance:
go mod tidy
Use golangci-lint exclusively. Do not use standalone formatters.
| Task | Command | Description |
|---|---|---|
| Check | golangci-lint run |
Runs all enabled linters and formatters. |
| Autofix | golangci-lint run --fix |
Applies linter fixes and formats code. |
| Format | golangci-lint fmt |
Runs configured v2 formatters only. |
Detect the existing layout or request guidance for new projects:
- Existing Projects: Detect if the project uses a Flat Layout (logic in root) or Standard Layout (using
internal/,pkg/, andcmd/). Follow the established pattern strictly. - New Projects: Do not assume a structure. Ask the user: "Would you prefer a Flat Layout or a Standard Go Project Layout (
internal/pkg/cmd)?" before creating directories.
- Build:
go build ./... - Test:
go test ./... - Race Check:
go test -race ./...
- Error Handling: Handle all errors explicitly. Do not use
_without a documented reason. - Documentation: Every exported identifier must have a comment starting with its name.
- V2 Config: Ensure
.golangci.ymlusesversion: "2". - LSP Warnings: Ignore unused imports/warnings from LSP; they will be resolved by the linter's autofix and formatter steps.
- Ensure
go mod tidyandgolangci-lint fmthave been run. - Summarize the changes made and list any new dependencies added so the human can review before committing.