developing-golang/SKILL.md
Guides Go development with best practices from Google Style Guide and Effective Go. Use when go.mod is detected or Go code is being written. Covers naming, error handling, concurrency, testing, and project structure.
npx skillsauth add juanjosegongi/skills developing-golangInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill consists of the following documents:
Best practices for naming in Go:
Robust error handling patterns:
Powerful concurrency patterns in Go:
How to write effective Go tests:
Recommended directory layout:
Leveraging the Go ecosystem:
// Good: Simple and clear
func ProcessItems(items []Item) error {
for _, item := range items {
if err := item.Process(); err != nil {
return fmt.Errorf("process item %s: %w", item.ID, err)
}
}
return nil
}
// Bad: Over-abstraction
func ProcessItems(items []Item, processor ItemProcessor, validator ItemValidator) error {
// Unnecessary complexity
}
// Good: Explicit error handling
result, err := doSomething()
if err != nil {
return err
}
// Bad: Ignoring errors
result, _ := doSomething()
// Good: Communication via channels
results := make(chan Result)
go func() {
results <- process(data)
}()
result := <-results
// Avoid: Communication by sharing memory (only when necessary)
var mu sync.Mutex
var shared int
# Create module
mkdir my-project && cd my-project
go mod init github.com/username/my-project
# Basic structure
mkdir -p cmd/myapp internal/my-context-1/application internal/my-context-1/infrastructure internal/my-context-2/application internal/my-context-2/infrastructure
package main
import (
"context"
"log"
"os"
"os/signal"
"syscall"
)
func main() {
ctx, cancel := signal.NotifyContext(context.Background(),
os.Interrupt, syscall.SIGTERM)
defer cancel()
if err := run(ctx); err != nil {
log.Fatal(err)
}
}
func run(ctx context.Context) error {
// Application logic
return nil
}
# Format
gofmt -w .
# Lint
golangci-lint run
# Test
go test ./...
# Build
go build -o bin/myapp ./cmd/myapp
// Good: Valid state with zero values
type Counter struct {
mu sync.Mutex
count int // Zero value is 0, which is valid
}
func (c *Counter) Inc() {
c.mu.Lock()
c.count++
c.mu.Unlock()
}
// Usable without explicit initialization
var c Counter
c.Inc()
// Good: Single-method interfaces
type Reader interface {
Read(p []byte) (n int, err error)
}
type Writer interface {
Write(p []byte) (n int, err error)
}
// Extend through composition
type ReadWriter interface {
Reader
Writer
}
// Good: Early return with guard clauses
func process(item *Item) error {
if item == nil {
return errors.New("item is nil")
}
if item.ID == "" {
return errors.New("item ID is empty")
}
// Main logic
return item.Save()
}
development
Guides Dockerfile creation and optimization. Use when Dockerfile or Docker Compose is detected. Supports multi-stage builds, cache optimization, security hardening, and image size minimization.
development
Provides comprehensive testing and TDD guidance. Use for writing tests before implementing new features (TDD, test-driven development, red-green-refactor), creating reproduction tests for bug fixes, running regression tests during refactoring, and checking test coverage during code reviews. Enforces AAA pattern, test-first workflow, and 100% business logic coverage goal. Also covers testing anti-patterns, mock discipline, and testable design.
data-ai
A completely different skill for database operations. Use when working with PostgreSQL queries, schema design, or database migrations.
testing
Another sample skill for testing. Use when the user wants to create widgets with advanced features or mentions beta testing.