go-logging

Installation
SKILL.md

Go Logging

Use log/slog (stdlib since Go 1.21) for structured logging. Pass the logger as an explicit dependency; the package-level global is a code smell.

For the comprehensive reference, see references/logging.md.

Three rules

  1. Logger is a dependency, not a global. Inject *slog.Logger through constructors.
  2. Structured everything. No fmt.Sprintf into the message — put the variables in attributes so they're queryable.
  3. Log or return, not both. If you return err, the caller logs. The lowest layer that handles the error logs once.

Constructor injection

Related skills
Installs
2
Repository
marsolab/skills
First Seen
3 days ago