cleanup: address golangci 'errcheck' issues

Many reports are about closing or removing files. In some cases it is
possible to report an error in the logs, in other cases the error can be
ignored without potential issues.

Test cases have been modified to not remove the temporary files. The
temporary directory that is provided by the testing package, is removed
once the tests are done.

Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
Niels de Vos
2025-05-02 17:33:29 +02:00
committed by mergify[bot]
parent 0a22e3a186
commit bc8b1e792f
19 changed files with 131 additions and 71 deletions

View File

@ -34,6 +34,7 @@ func CreateTempFile(prefix, contents string) (*os.File, error) {
// In case of error, remove the file if it was created
defer func() {
if err != nil {
//nolint:errcheck // temporary file failed to remove, shrug
_ = os.Remove(file.Name())
}
}()