From f193e313a3e8590ba78cde39a9fed39ade956f66 Mon Sep 17 00:00:00 2001 From: Viktor Vassilyev Date: Wed, 7 Nov 2018 20:21:34 +0600 Subject: [PATCH] refactor(FileSystem): using single-line if --- fs.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs.go b/fs.go index 7e5b343d..cda63c6c 100644 --- a/fs.go +++ b/fs.go @@ -41,8 +41,7 @@ func walk(fs http.FileSystem, path string, info os.FileInfo, walkFn filepath.Wal dir, err := fs.Open(path) defer dir.Close() if err != nil { - err1 := walkFn(path, info, err) - if err1 != nil { + if err1 := walkFn(path, info, err); err1 != nil { return err1 } return err @@ -62,8 +61,7 @@ func walk(fs http.FileSystem, path string, info os.FileInfo, walkFn filepath.Wal for _, fileInfo := range dirs { filename := filepath.Join(path, fileInfo.Name()) - err = walk(fs, filename, fileInfo, walkFn) - if err != nil { + if err = walk(fs, filename, fileInfo, walkFn); err != nil { if !fileInfo.IsDir() || err != filepath.SkipDir { return err }