xdg: Add the hability to initialize a new BaseDir with different FS behind #36
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This allows to not only use the machine FS but any other supported by afero.Fs in this case.
This is a PoC PR as I want to be sure this is a correct way to do it in your opinion, for me it looks clean and requires no changes for people already using this lib.
The idea behind is to have the
BaseDirectories
be able to be initialized with anafero.Fs
and make it public so anyone could choose what to do. By default thebaseDir
is initialized withafero.NewOsFs()
which uses the stdlib of GO foros
so it works as it worked before.Another solution would be to have a global variable with the FS to use but I really hate to use global variables for this things, and having a way to initialize different xdg with different FS makes it easy to use IMO.
We could also make the variable
BaseDir
public or add a public function to change that value instead of having theNew
but I had the same feeling of global things not beeing that useful and easy to use/understand.If this changes where to be on the right way there are a few things still to be done:
afero.NewMemMapFs
which is an in-memory implementation of a FS, quite useful for testing.Whenever you have time take a look and if it's ok I'll continue with the things I mention to finish or any other thing you may want or suggestion to change :).
Closes #35