From 4cb6bde42ce1edc1194c6639aea930a02a9c5f30 Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Tue, 18 Jan 2022 18:10:17 +0100 Subject: [PATCH] Clean up file output handler error handling The "= nil" assignment isn't necessary. Merge the error handling, and drop the empty "if outputHandler != nil" branch. Signed-off-by: Stephen Kitt --- internal/pkg/output/file-output-handlers.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/internal/pkg/output/file-output-handlers.go b/internal/pkg/output/file-output-handlers.go index e4470ad007..b5e1df510b 100644 --- a/internal/pkg/output/file-output-handlers.go +++ b/internal/pkg/output/file-output-handlers.go @@ -149,33 +149,25 @@ func (manager *MultiOutputHandlerManager) getOutputHandlerFor( // TODO: LRU with close and re-open in case too many files are open outputHandler := manager.outputHandlers[filename] if outputHandler == nil { - var err error = nil + var err error if manager.pipe { outputHandler, err = NewPipeWriteOutputHandler( filename, manager.recordWriterOptions, ) - if err != nil { - return nil, err - } - if outputHandler != nil { - } } else if manager.append { outputHandler, err = NewFileAppendOutputHandler( filename, manager.recordWriterOptions, ) - if err != nil { - return nil, err - } } else { outputHandler, err = NewFileWriteOutputHandler( filename, manager.recordWriterOptions, ) - if err != nil { - return nil, err - } + } + if err != nil { + return nil, err } manager.outputHandlers[filename] = outputHandler }