Skip to content

Commit 53d6131

Browse files
schuellerfmvo5
authored andcommitted
bib/cmd/bootc-image-builder: check error of file.Close() when writing
Uses the named return value `err` to return possible errors.
1 parent 52627da commit 53d6131

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

bib/cmd/bootc-image-builder/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"encoding/json"
5+
"errors"
56
"fmt"
67
"io"
78
"log"
@@ -166,7 +167,7 @@ func makeManifest(c *ManifestConfig, solver *dnfjson.Solver, cacheRoot string) (
166167
return mf, depsolvedRepos, nil
167168
}
168169

169-
func saveManifest(ms manifest.OSBuildManifest, fpath string) error {
170+
func saveManifest(ms manifest.OSBuildManifest, fpath string) (err error) {
170171
b, err := json.MarshalIndent(ms, "", " ")
171172
if err != nil {
172173
return fmt.Errorf("failed to marshal data for %q: %s", fpath, err.Error())
@@ -176,8 +177,7 @@ func saveManifest(ms manifest.OSBuildManifest, fpath string) error {
176177
if err != nil {
177178
return fmt.Errorf("failed to create output file %q: %s", fpath, err.Error())
178179
}
179-
// nolint:errcheck
180-
defer fp.Close()
180+
defer func() { err = errors.Join(err, fp.Close()) }()
181181
if _, err := fp.Write(b); err != nil {
182182
return fmt.Errorf("failed to write output file %q: %s", fpath, err.Error())
183183
}

0 commit comments

Comments
 (0)