docs: update Go code style guidelines and linting requirements
CI / changes (push) Successful in 8s
CI / commitlint (push) Has been skipped
CI / openapi (push) Successful in 27s
CI / web (push) Successful in 36s
CI / go (push) Successful in 54s
CI / bird2 (push) Successful in 16s
CI / release (push) Successful in 3m46s

- Enhanced AGENTS.md to include post-editing commands for Go code, specifying the use of `gofmt -w`, `go vet ./...`, and `scripts/lint-go.ps1`.
- Updated engineering rules in .cursor/rules/engineering.mdc to clarify the linting process and ensure consistency in Go code formatting.
- Improved documentation for CI checks related to Go code style and linting.
This commit is contained in:
Denozordec
2026-05-21 12:50:14 +07:00
parent b8170c4204
commit 6fa265a246
7 changed files with 81 additions and 40 deletions
+5 -4
View File
@@ -57,9 +57,9 @@ alwaysApply: true
## Code Style ## Code Style
**STYLE-01** | MUST | Go-код после `gofmt`; перед PR — `go vet ./...`. **STYLE-01** | MUST | Go-код после `gofmt`; перед PR — `go vet ./...`. Агент после правок Go: `gofmt -w` на изменённых файлах + `golangci-lint run` (или `scripts/lint-go.*`) до exit 0.
*Rationale:* единый стиль. *Rationale:* CI job `go` включает golangci-lint (gofmt).
*Проверка:* CI job `go`. *Проверка:* CI job `go`; `.cursor/rules/engineering.mdc` STYLE-01.
**STYLE-02** | MUST | Экспортируемые типы/функции публичных пакетов — godoc-комментарий. **STYLE-02** | MUST | Экспортируемые типы/функции публичных пакетов — godoc-комментарий.
*Rationale:* навигация по API пакетов. *Rationale:* навигация по API пакетов.
@@ -230,7 +230,8 @@ alwaysApply: true
go vet ./... go vet ./...
go test ./... -race -count=1 go test ./... -race -count=1
npx @redocly/cli lint docs/openapi.yaml npx @redocly/cli lint docs/openapi.yaml
# web: cd web; npm run check; npm run lint # web: cd web; npm run check; npm run lint (или scripts/lint-web.ps1)
# go fmt/lint: gofmt -w <files>; scripts/lint-go.ps1 (gofmt + vet + golangci-lint)
# birdfmt: go test ./internal/birdfmt/... -count=1 # birdfmt: go test ./internal/birdfmt/... -count=1
``` ```
+1
View File
@@ -51,6 +51,7 @@
- Консоль пользователя: **PowerShell**; пути в стиле `deploy\compose`. - Консоль пользователя: **PowerShell**; пути в стиле `deploy\compose`.
- Быстрый старт и переменные: [docs/quickstart.md](docs/quickstart.md), [README.md](README.md). - Быстрый старт и переменные: [docs/quickstart.md](docs/quickstart.md), [README.md](README.md).
- **Go:** после правок — `gofmt -w`, `go vet ./...`, `scripts/lint-go.ps1` (как CI golangci-lint).
## Язык документации проекта ## Язык документации проекта
+19
View File
@@ -0,0 +1,19 @@
# Same gates as CI job go (subset): gofmt, vet, golangci-lint.
$ErrorActionPreference = 'Stop'
Set-Location (Join-Path $PSScriptRoot '..')
$unfmt = gofmt -l . 2>$null
if ($unfmt) {
Write-Error "gofmt: unformatted files:`n$unfmt"
}
go vet ./...
$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
} else {
Write-Warning 'lint-go: golangci-lint not found, skipping (CI will run it)'
}
+20
View File
@@ -0,0 +1,20 @@
#!/bin/sh
# Same gates as CI job go (subset before full test): gofmt, vet, golangci-lint.
set -euxo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
UNFMT="$(gofmt -l .)"
if [ -n "$UNFMT" ]; then
echo "gofmt: unformatted files:" >&2
echo "$UNFMT" >&2
exit 1
fi
go vet ./...
if command -v golangci-lint >/dev/null 2>&1; then
golangci-lint run
else
echo "lint-go: golangci-lint not in PATH, skipping (CI will run it)" >&2
fi