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

Custom file system support? #35

Open
nathanhammond opened this issue May 3, 2022 · 5 comments · May be fixed by #36
Open

Custom file system support? #35

nathanhammond opened this issue May 3, 2022 · 5 comments · May be fixed by #36

Comments

@nathanhammond
Copy link

Hello @adrg! Would you be interested in a pull request that enabled custom file system support? (e.g. afero)

@adrg
Copy link
Owner

adrg commented May 3, 2022

Hi @nathanhammond. Thank you for your interest in the library. Sure, that would be great.

I assume the PR would add an interface which defines all permitted file system operations and a 'local fs' implementation of that interface, which would be the default?

@nathanhammond
Copy link
Author

If that's the implementation that you feel like makes the most sense, then, yes!

I'll get you a draft PR for your consideration up shortly.

@adrg
Copy link
Owner

adrg commented May 3, 2022

Sorry, I was just wondering if you were thinking of something along those lines 😄.
I'm not sure if it's the best way to do it, just my initial thoughts on this.

@xescugc
Copy link

xescugc commented May 18, 2022

@nathanhammond are you working on it? Because I'm also interested in it hehe.

@DanInProgress
Copy link

I was mulling over porting an internal tool's config system to use more standard directories over an upcoming lull and might be able to pick this up if wanted by @adrg .

Off-topic Background
For my own usage/needs, I need something equivalent to fs.Glob
or fs.WalkDir, to replicate a behavior where end-user config files
are merged with system provided files
(e.g. defaults.yml,user_config.yml, local_creds.yml)

I've done relatively little research thus far, but noticed that the open pull
request used afero. If possible, I'll attempt to use io/fs in my design since that's now definitely stable.

Seeking input on some possibilities (very rough sketch):

  • var values whose value or values implement io/fs.FS
    • declared like var DataHomeFS fs.FS to maintain backward compat
    • at its simplest set as os.DirFS(DataHome)
    • facilitates mocking/fallback injection
  • var values that themselves implement io/fs.FS
    • enabling an interface like fs.Glob(xdg.DataDirsFS,"appname/*.sh")

Uncertain how much performance penalty the added indirection would cause, and so feels like unit/performance tests are warranted. Just wanted to get your thoughts before spending addl time evaluating it next month.

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 a pull request may close this issue.

4 participants