This file applies to the entire repository.
- Go CLI for managing JIRA/Gerrit/git workflow.
- Configuration lives at
~/.beer.yamlby default (override with--config). - Key commands:
beer brew,beer taste(seeREADME.md). - CI runs Go
^1.25andgolangci-lint.
Run these from repo root unless noted.
go mod download
go build -v ./...
golangci-lint run ./...
go test -v ./...
- Run a specific test by name:
go test ./... -run TestName -count=1 - Run a specific package:
go test ./cmd -run TestName -count=1 - Short mode (if tests honor it):
go test ./... -short
gofmt -w <files>(always run on modified Go files)
- Dry run:
make release-dry-run - Publish:
make release(requires.release-env)
These mirror the project standards and existing code.
- Keep changes small and focused.
- Favor pure, testable functions; refactor if tests are hard.
- Use explicit dependencies; avoid hidden globals.
- Prefer declarative logic over nested imperative loops.
- Follow standard Go idioms and
gofmtformatting. - Use
goimportsif available to keep imports tidy. - Keep functions small (ideally < 50 lines).
- Use early returns to avoid deep nesting.
- Avoid unnecessary interfaces; accept concrete types unless needed.
- Group standard library, third-party, and local imports.
- Keep imports alphabetical within groups.
- Remove unused imports before committing.
- Use Go naming conventions:
camelCasefor locals,PascalCasefor exported. - Prefer descriptive names:
configPathovercp. - Predicates should read like booleans:
isDraft,hasConfig. - Constants use
lowerCamelunless exported.
- Favor explicit types in public APIs and interfaces.
- Keep structs focused; avoid god-structs.
- Prefer value types unless mutation is required.
- Handle errors explicitly; do not ignore return values.
- Add context with
fmt.Errorf("...: %w", err)when returning. - Avoid
panicin CLI flow; return errors orlog.Fatalwith context. - Don’t leak secrets in logs or error messages.
- Use
logrusas seen in existing code. - Include context fields when helpful (e.g., IDs, config keys).
- Debug logs are fine; avoid noisy info logs by default.
- Keep external integrations optional/configurable.
- Never hardcode secrets or tokens.
- Validate inputs at boundaries; sanitize user-provided strings.
- Be cautious when reading config defaults.
- Keep command descriptions short and actionable.
- Errors should be clear and actionable.
- Respect
--dry-runsemantics where present.
- Use AAA pattern (Arrange → Act → Assert).
- Test behavior, not implementation.
- Include happy path, edge cases, and error cases.
- Prefer deterministic tests with minimal setup.
- Update
README.mdfor user-facing changes. - Document the “why” for non-obvious behavior.
- No Cursor or Copilot rules found in
.cursor/rules/,.cursorrules, or.github/copilot-instructions.md. - Config file defaults are user-facing; avoid changing them unless required.
README.mdfor configuration and common workflow..golangci.ymlfor lint defaults..github/workflows/pr.yamlfor CI build/test commands.
(If in doubt, gofmt. It’s the tabular path to enlightenment.)