diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2022-03-26 06:39:11 -0400 |
---|---|---|
committer | Matthew Heon <mheon@redhat.com> | 2022-03-30 15:36:05 -0400 |
commit | b362367efb7ecbe8aadeac3f5f4d5d17fe27862b (patch) | |
tree | 73ae0d46e7854d787c7d9b8fdfe9c8244f607ee6 /pkg/machine/wsl | |
parent | 713ce2a96724e14a6a2acfcb93902826f0c4d2e2 (diff) | |
download | podman-b362367efb7ecbe8aadeac3f5f4d5d17fe27862b.tar.gz podman-b362367efb7ecbe8aadeac3f5f4d5d17fe27862b.tar.bz2 podman-b362367efb7ecbe8aadeac3f5f4d5d17fe27862b.zip |
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 <dwalsh@redhat.com>
Diffstat (limited to 'pkg/machine/wsl')
-rw-r--r-- | pkg/machine/wsl/machine.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/pkg/machine/wsl/machine.go b/pkg/machine/wsl/machine.go index 5b0c757f0..5128fa313 100644 --- a/pkg/machine/wsl/machine.go +++ b/pkg/machine/wsl/machine.go @@ -8,6 +8,7 @@ import ( "encoding/json" "fmt" "io" + "io/fs" "io/ioutil" "net/url" "os" @@ -1175,10 +1176,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 |