From d106b294b428fbb10f59d4cafe72c3dcaa4e73bb Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Sat, 26 Mar 2022 06:39:11 -0400 Subject: Switch all calls to filepath.Walk to filepath.WalkDir WalkDir should be faster the Walk, since we often do not need to stat files. [NO NEW TESTS NEEDED] Existing tests should find errors. Signed-off-by: Daniel J Walsh --- pkg/machine/qemu/machine.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'pkg/machine/qemu') diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go index ffc90b2a0..f04625781 100644 --- a/pkg/machine/qemu/machine.go +++ b/pkg/machine/qemu/machine.go @@ -895,10 +895,10 @@ func GetVMInfos() ([]*machine.ListResponse, error) { var listed []*machine.ListResponse - if err = filepath.Walk(vmConfigDir, func(path string, info os.FileInfo, err error) error { + if err = filepath.WalkDir(vmConfigDir, func(path string, d fs.DirEntry, err error) error { vm := new(MachineVM) - if strings.HasSuffix(info.Name(), ".json") { - fullPath := filepath.Join(vmConfigDir, info.Name()) + if strings.HasSuffix(d.Name(), ".json") { + fullPath := filepath.Join(vmConfigDir, d.Name()) b, err := ioutil.ReadFile(fullPath) if err != nil { return err -- cgit v1.2.3-54-g00ecf