Duplicate Log Message (ARCH5162)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Key go.logging.duplicate-log-message · Severity info · Category logging
Repeating identical log message strings within the same file or module makes a log line ambiguous about which code path produced it. Each message should distinguish its source.
Incorrect
Section titled “Incorrect”func update(log *slog.Logger, ok bool) { if !ok { log.Warn("operation failed") } if err := commit(); err != nil { log.Warn("operation failed") }}Correct
Section titled “Correct”func update(log *slog.Logger, ok bool) { if !ok { log.Warn("validation failed") } if err := commit(); err != nil { log.Warn("commit failed", "err", err) }}Give each log call a unique message that disambiguates its context.