Canonical guidance

Use when

Avoid

Preferred pattern

type Service struct {
	Repo UserRepo
	Log  *slog.Logger
}

func NewService(repo UserRepo, log *slog.Logger) *Service {
	return &Service{Repo: repo, Log: log}
}

Anti-pattern

Explanation: This anti-pattern is tempting because containers promise flexibility, but in Go they often hide control flow without reducing real complexity.

Why

Related pages

Sources