diff --git a/afero_test.go b/afero_test.go index 26e23cd..fee91f9 100644 --- a/afero_test.go +++ b/afero_test.go @@ -394,13 +394,13 @@ func TestWriteAt(t *testing.T) { } f2, err := fs.Open(f.Name()) + if err != nil { + t.Fatalf("%v: ReadFile %s: %v", fs.Name(), f.Name(), err) + } defer f2.Close() buf := new(bytes.Buffer) buf.ReadFrom(f2) b := buf.Bytes() - if err != nil { - t.Fatalf("%v: ReadFile %s: %v", fs.Name(), f.Name(), err) - } if string(b) != "hello, WORLD\n" { t.Fatalf("after write: have %q want %q", string(b), "hello, WORLD\n") } diff --git a/util.go b/util.go index cec6f8f..2f44e6a 100644 --- a/util.go +++ b/util.go @@ -295,10 +295,10 @@ func IsEmpty(fs Fs, path string) (bool, error) { } if fi.IsDir() { f, err := fs.Open(path) - defer f.Close() if err != nil { return false, err } + defer f.Close() list, err := f.Readdir(-1) return len(list) == 0, nil }