hoangnguyen0403-language
SKILL.md
Golang Language Standards
Priority: P0 (CRITICAL)
Guidelines
- Fmt: Run
gofmtorgoimportson save. - Naming: Use
camelCasefor internal,PascalCasefor exported. - Packages: Short, lowercase, singular, no underscores (e.g.,
net/httpnotnet_http). - Interfaces: Define where used, not where implemented. Small interfaces (1-2 methods).
- Errors: Return error as last return value. Handle immediately.
- Variables: Short names for small scope (
i,ctx), descriptive for large scope. - Slices: Prefer slices over arrays. Use
make()for capacity. - Const: Use
iotafor enums.
Anti-Patterns
- No
init: Use constructors, notinit(). - No Globals: Use DI, not global mutable state.
- No
panic: Return errors, don't panic. - No
_ignored errors: Always check and handle errors. - No stutter:
log.Error, notlog.LogError.