Skip to content

Commit 45e0a92

Browse files
committed
Move nil check into FileDiagnosticsWriter implementation of WriteDiagnostic
1 parent 8e7d626 commit 45e0a92

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

go/extractor/diagnostics/diagnostics.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ type FileDiagnosticsWriter struct {
6565
}
6666

6767
func (writer *FileDiagnosticsWriter) WriteDiagnostic(d diagnostic) {
68+
if writer == nil {
69+
return
70+
}
71+
6872
content, err := json.Marshal(d)
6973
if err != nil {
7074
slog.Error("Failed to encode diagnostic as JSON", slog.Any("err", err))
@@ -142,9 +146,6 @@ func emitDiagnosticTo(writer DiagnosticsWriter, sourceid, sourcename, markdownMe
142146

143147
// Emits a diagnostic using the default `DiagnosticsWriter`.
144148
func emitDiagnostic(sourceid, sourcename, markdownMessage string, severity diagnosticSeverity, visibility *visibilityStruct, location *locationStruct) {
145-
if DefaultWriter == nil {
146-
return
147-
}
148149
emitDiagnosticTo(DefaultWriter, sourceid, sourcename, markdownMessage, severity, visibility, location)
149150
}
150151

0 commit comments

Comments
 (0)