From f3f0b47da99ea1f4d975ce879fffef64ab131d11 Mon Sep 17 00:00:00 2001 From: Kevin Mulvey Date: Tue, 9 Apr 2024 14:40:41 -0600 Subject: [PATCH] linting; --- pkg/imagedup/logger/logger.go | 7 +++++-- pkg/imagedup/logger/logger_test.go | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/imagedup/logger/logger.go b/pkg/imagedup/logger/logger.go index 6d500e8..42bf149 100644 --- a/pkg/imagedup/logger/logger.go +++ b/pkg/imagedup/logger/logger.go @@ -38,7 +38,10 @@ func NewDeleteLogger(filename string) (*DeleteLogger, error) { } // write the header - file.WriteString("[") + _, err = file.WriteString("[") + if err != nil { + return nil, fmt.Errorf("DeleteLogger could not write the leading [ to the file: %s, err: %w", filename, err) + } return &DeleteLogger{FileName: filename, LogFile: file, FirstEntry: true}, nil } @@ -60,7 +63,7 @@ func ReadDeleteLogFile(filename string) ([]DeleteEntry, error) { return entries, nil } -// LogResult logs a single duplicate result as json. Each record is writted to disk immediatly as to not use too much RAM. +// LogResult logs a single duplicate result as json. Each record is writted to disk immediately as to not use too much RAM. func (dl *DeleteLogger) LogResult(result hash.DiffResult) error { var entry DeleteEntry diff --git a/pkg/imagedup/logger/logger_test.go b/pkg/imagedup/logger/logger_test.go index a6554b3..65b5a8f 100644 --- a/pkg/imagedup/logger/logger_test.go +++ b/pkg/imagedup/logger/logger_test.go @@ -18,20 +18,22 @@ func TestCustomLogger(t *testing.T) { assert.NoError(t, err) // one is bigger - logger.LogResult(hash.DiffResult{ + err = logger.LogResult(hash.DiffResult{ One: "fileone", Two: "filetwo", OneArea: 20, TwoArea: 10, }) + assert.NoError(t, err) // two is bigger - logger.LogResult(hash.DiffResult{ + err = logger.LogResult(hash.DiffResult{ One: "fileone", Two: "filetwo", OneArea: 10, TwoArea: 20, }) + assert.NoError(t, err) assert.NoError(t, logger.Close()) deletes, err := ReadDeleteLogFile(filename)