golang
Expert Go developer guide. Use when writing, debugging, or reviewing Go code.
When & Why to Use This Skill
This Claude skill serves as an expert guide for Go (Golang) development, designed to streamline the process of writing, debugging, and reviewing high-quality code. It enforces industry-standard best practices, including structured logging with the `slog` package, idiomatic interface definitions, and robust table-driven testing. By integrating essential developer tools like `golangci-lint` and `make`, it ensures that your Go projects are maintainable, performant, and compliant with modern coding standards.
Use Cases
- Idiomatic Go Development: Generate Go code that follows strict architectural rules, such as defining interfaces where they are consumed and using structured logging for better observability.
- Automated Testing and QA: Implement and run table-driven tests to ensure comprehensive logic coverage and clear failure reporting within the Go testing framework.
- Code Quality Enforcement: Utilize integrated linting tools like `golangci-lint` via Bash commands to automatically detect and fix style inconsistencies and potential bugs.
- Efficient Code Reviews: Analyze existing Go repositories to ensure compliance with project-specific rules, such as restricting command-line flag access to the main function.
| name | golang |
|---|---|
| description | Expert Go developer guide. Use when writing, debugging, or reviewing Go code. |
| allowed-tools | Bash, Read, Grep, Glob, Edit, Write |
Go Development Skill
Instructions
When working with Go code, follow these rules:
- Logging: Use the
log/slogpackage in the standard library.- Add appropriate log messages with proper log levels.
- Interfaces: Define interfaces where they are used, not where they are implemented.
- Avoid introducing unused interfaces.
- Testing:
- Use table-driven tests.
- Clarify which case is failing in the test log.
- Linting:
- Run
make lintto check for issues. - Run
make fixto auto-fix issues. - If running manually:
golangci-lint run ./...
- Run
- Flags: Only the
mainfunction can access command-line flags.
Tools
- Lint:
make lint - Test:
make test