diff --git a/fsutil/operate_test.go b/fsutil/operate_test.go index b716efcb1..d70c6d974 100644 --- a/fsutil/operate_test.go +++ b/fsutil/operate_test.go @@ -111,7 +111,6 @@ func TestMustOpenFile(t *testing.T) { of := fsutil.MustOpenFile(fpath, fsutil.FsRWFlags, 0600) assert.Eq(t, "must-open-file", fsutil.ReadString(of)) - assert.NoErr(t, of.Close()) } func TestOpenAppendFile(t *testing.T) { diff --git a/fsutil/opread.go b/fsutil/opread.go index 71ed98457..8cbb0f234 100644 --- a/fsutil/opread.go +++ b/fsutil/opread.go @@ -87,12 +87,12 @@ func ReadOrErr(in any) ([]byte, error) { r, err := NewIOReader(in) defer func() { if r != nil { - file, ok := r.(*os.File) - if ok { + if file, ok := r.(*os.File); ok { err = file.Close() } } }() + if err != nil { return nil, err }