-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: replacing afero.Fs with fs.FS #17
Conversation
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Not to be merged before go 1.16 stable is out... |
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
setup-go action don't support go tip 😞 |
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
glob.go
Outdated
@@ -80,14 +83,21 @@ func toNixPath(path string) string { | |||
|
|||
// Glob returns all files that match the given pattern in the current directory. | |||
func Glob(pattern string, opts ...OptFunc) ([]string, error) { | |||
prefix := "./" | |||
if strings.HasPrefix(pattern, stringSeparator) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure about this part yet... DirFS won't allow to start on /
, so to keep the API I'm doing this little hack here... but maybe we can just declare it a breaking change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by that? prefix = stringSeparator
and WithFS(os.DirFS(prefix))
seems like you are doing exactly that.
As far as I understand the docs, os.DirFS
has no concept of a current working directy. So normally I would expect the fs to be os.DirFS("/")
so I can access everything. But if I open file
I would expect it to open /cwd/file
where /cwd
is my current working directory. But instead, os.DirFS("/") opens
/file`. So what we would need to keep track of is the current working directory right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fs.Open only accepts relative dirs
but I think this is indeed outside of the API.
Before it was also only working on paths relative to current, and didn't accept absolute paths anyway (/etc/foo/bar.conf
for example)
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Codecov Report
@@ Coverage Diff @@
## main #17 +/- ##
==========================================
- Coverage 83.67% 82.90% -0.77%
==========================================
Files 2 2
Lines 98 117 +19
==========================================
+ Hits 82 97 +15
- Misses 9 12 +3
- Partials 7 8 +1
Continue to review full report at Codecov.
|
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
@erikgeiser I think its good to be reviewed again. I make the Root path stuff an Option (and also added a "print options" option, for debugging et al). Basically, by default, we start in current working dir ( Prefix is needed in the case of "RootFS" because all results will be relative to the FS (in this case, |
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This reverts commit 2862f40.
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This reverts commit 114fbc8.
This reverts commit ffb6804.
This reverts commit 33835d6.
This reverts commit 2089e0f.
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
at the cost of my sanity, it is now working on windows |
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
BREAKING CHANGE: stop using
afero.Fs
and use the newfs.FS
package instead.Also improves windows support all over the place.