Files
everything-claude-code/docs/es/rules/golang/patterns.md
Santiago González Siordia ac0f11c640 docs: add Spanish (es) translation (#2095)
Adds a complete Spanish translation of the ECC documentation under
docs/es/, mirroring the Turkish (docs/tr/) translation in scope.
141 files covering agents, commands, rules, skills, contexts, examples,
and core docs. Updates root README.md with the Spanish language link.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 13:26:42 +08:00

46 lines
918 B
Markdown

---
paths:
- "**/*.go"
- "**/go.mod"
- "**/go.sum"
---
# Patrones de Go
> Este archivo extiende [common/patterns.md](../common/patterns.md) con contenido específico de Go.
## Functional Options
```go
type Option func(*Server)
func WithPort(port int) Option {
return func(s *Server) { s.port = port }
}
func NewServer(opts ...Option) *Server {
s := &Server{port: 8080}
for _, opt := range opts {
opt(s)
}
return s
}
```
## Interfaces Pequeñas
Definir las interfaces donde se usan, no donde se implementan.
## Inyección de Dependencias
Usar funciones constructor para inyectar dependencias:
```go
func NewUserService(repo UserRepository, logger Logger) *UserService {
return &UserService{repo: repo, logger: logger}
}
```
## Referencia
Ver skill: `golang-patterns` para patrones completos de Go incluyendo concurrencia, manejo de errores y organización de paquetes.