Print Instead Of Logger (ARCH5157)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Key go.logging.fmt-print-instead-of-logger · Severity warning · Category logging
Writing directly to stdout/stderr with fmt.Println or fmt.Printf bypasses the structured logger that provides levels, structure, and sink routing. Diagnostic output should go through the framework logger.
Incorrect
Section titled “Incorrect”func handle(req *Request) { fmt.Println("processing request", req.ID) // ...}Correct
Section titled “Correct”func handle(req *Request, log *slog.Logger) { log.Info("processing request", "id", req.ID) // ...}Use a structured logger (log/slog) instead of fmt.Print*.