Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refact: replace filepath.Walk into filepath.WalkDir #70

Merged
merged 2 commits into from
Jun 5, 2022

Conversation

HurSungYun
Copy link
Contributor

@HurSungYun HurSungYun commented Jan 31, 2022

From Go 1.16 docs:

Walk is less efficient than WalkDir, introduced in Go 1.16, which avoids calling os.Lstat on every visited file or directory.

The differences between WalkDirFunc compared to filepath.WalkFunc are:

  • The second argument has type fs.DirEntry instead of fs.FileInfo.
  • The function is called before reading a directory, to allow SkipDir to bypass the directory read entirely.
  • If a directory read fails, the function is called a second time for that directory to report the error.

This change would make some performance improvements when lots of directories are matched with given flagExcludedDirs pattern.

Currently, CompileDaemon requires Go 1.11 or higher but WalkDir are introduced in Go 1.16. Thus, Go 1.16 or higher version will be needed after merging this PR.

Feel free to close this PR if you don't want to update Go version now.

@githubnemo
Copy link
Owner

Thanks, this seems reasonable :)

@githubnemo githubnemo merged commit 887a6fc into githubnemo:master Jun 5, 2022
asalkeld pushed a commit to asalkeld/CompileDaemon that referenced this pull request Aug 4, 2022
* refact: replace filepath.Walk into filepath.WalkDir

* dep: update go version to 1.16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants