id: no-fmt-println
language: Go
severity: warning
message: Avoid `fmt.Println` in production code; use a structured logger.
note: |
Direct console output via `fmt.Println` is not configurable and cannot be
routed to log aggregators. Use `log/slog` (Go 1.21+) or a structured
logging library for production code. `fmt.Println` is acceptable in
tests, examples, and CLI tools.
rule:
any:
- pattern: $FUNC($$$)
constraints:
FUNC:
regex: "^fmt\\.(Println|Printf|Fprintln|Fprint|Fprintf)$"
has:
kind: field_identifier
files:
- "**/*.go"
- "!**/*_test.go"
- "!**/examples/**"