code-like-gopherlisted
Install: claude install-skill vigo/claude-skills
## When to Use
Use this skill when:
- Writing, reviewing, or refactoring Go code
- Setting up Go project structure and tooling
- Debugging concurrency issues
- Configuring linters and formatters
- Writing idiomatic Go code
## Prerequisites Check
Before starting any Go work:
```bash
# Check Go version
go version
# Check go.mod version requirement
grep '^go ' go.mod 2>/dev/null | awk '{print $2}'
# Check if golangci-lint is available
command -v golangci-lint
```
---
## Instructions
### General Coding Approach
- All naming and comments must be in **English**
- Always check the Go version in `go.mod` and use appropriate language features
- Starting with **Go 1.22+**, the loop variable capture issue is fixed
- Starting with **Go 1.23+**, range-over-integers is available:
```go
// Go 1.23+ only
for i := range 10 {
fmt.Println(i)
}
// Go 1.22+ - loop variable capture is safe
for i := range items {
go func() {
fmt.Println(i) // safe, no need for tt := tt
}()
}
```
---
### Formatting and Linting
**golangci-lint** is the standard tool for Go code quality.
```bash
# Install if missing
brew install golangci-lint # macOS
# or
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
```
Check for existing config files:
- `.golangci.yml` / `.golangci.yaml`
- `.golangci.toml` / `.golangci.json`
If config version is not `"2"`, migrate:
```bash
golangci-lint migrate
```
#### Minimal `.golangci.yml` Config
```yaml
version: "2"
run: