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

Add a "Exists" function to fsutil #24

Merged
merged 1 commit into from
Nov 6, 2024
Merged

Conversation

djjuhasz
Copy link
Contributor

@djjuhasz djjuhasz commented Nov 6, 2024

I copied the FileExists() function from https://github.com/artefactual-sdps/preprocessing-sfa/blob/main/internal/fsutil/fsutil.go. I need the function in https://github.com/artefactual-sdps/preprocessing-demo and I think we've re-implemented it in several other projects, so I think it's a good candidate for gotools.

@djjuhasz djjuhasz requested review from sevein and jraddaoui November 6, 2024 17:45
Copy link
Member

@sevein sevein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of suggestions:

  • Renaming the method to fsutil.Exists would clarify that it checks for both files and directories, treating them the same way.
  • We should avoid hiding the error because changing the function's signature later to include it would be a backward-incompatible change. Here's an example that you could use. Users can still choose to ignore the error if it's not needed.

@djjuhasz
Copy link
Contributor Author

djjuhasz commented Nov 6, 2024

@sevein okay, done.

@djjuhasz djjuhasz requested a review from sevein November 6, 2024 22:26
Copy link
Member

@sevein sevein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Exists returns true if a file or directory exist at the given path and
false if one doesn't.
@djjuhasz djjuhasz force-pushed the dev/add-fsutil-file-exists branch from 628176a to 3d188fc Compare November 6, 2024 22:42
@djjuhasz djjuhasz merged commit 089f7c8 into main Nov 6, 2024
6 checks passed
@djjuhasz djjuhasz deleted the dev/add-fsutil-file-exists branch November 6, 2024 22:45
@djjuhasz djjuhasz changed the title Add a FileExists function to fsutil Add a "Exists" function to fsutil Nov 6, 2024
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.

2 participants