diff options
author | Sebastiaan van Stijn <github@gone.nl> | 2022-10-09 17:26:31 +0200 |
---|---|---|
committer | Sebastiaan van Stijn <github@gone.nl> | 2022-10-09 17:26:31 +0200 |
commit | 402e0b58ca1b1e537b92348e68f5e6bd08709ddb (patch) | |
tree | 8a013f194e8e0858d8994016d28b338c0730b8c7 | |
parent | 3db11af44b76b6554ff37799de56a36bd22b3c6d (diff) | |
download | docker-402e0b58ca1b1e537b92348e68f5e6bd08709ddb.tar.gz |
testutil: use filepath.WalkDir instead of filepath.Walk
WalkDir is more performant as it doesn't perform an os.Lstat on every visited
file or directory.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
-rw-r--r-- | testutil/daemon/daemon_linux.go | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/testutil/daemon/daemon_linux.go b/testutil/daemon/daemon_linux.go index 720c52a436..0cff545fd1 100644 --- a/testutil/daemon/daemon_linux.go +++ b/testutil/daemon/daemon_linux.go @@ -18,8 +18,7 @@ func cleanupNetworkNamespace(t testing.TB, d *Daemon) { // daemon instance and has no chance of getting // cleaned up when a new daemon is instantiated with a // new exec root. - netnsPath := filepath.Join(d.execRoot, "netns") - filepath.Walk(netnsPath, func(path string, info os.FileInfo, err error) error { + filepath.WalkDir(filepath.Join(d.execRoot, "netns"), func(path string, _ os.DirEntry, _ error) error { if err := unix.Unmount(path, unix.MNT_DETACH); err != nil && err != unix.EINVAL && err != unix.ENOENT { t.Logf("[%s] unmount of %s failed: %v", d.id, path, err) } |