5 ms·
I'm excited about io/fs[1]. As a newcomer to Go, one of my favorite things is the excellent I/O interfaces. I can write code to take io.Writer's or io.Reader's
by kevlar1818 6y ago
I'm excited about io/fs[1]. As a newcomer to Go, one of my favorite things is the excellent I/O interfaces. I can write code to take io.Writer's or io.Reader's (etc.) and my program is suddenly both a CLI app, a Web app, and a Whatever app with minimal effort. (The effect is similar at lower levels too. For example, I can log to a file or to memory with a one-line change.) I sense a lot of potential in applying this interface-based design on filesystems themselves.
[1]: https://tip.golang.org/pkg/io/fs/ https://tip.golang.org/pkg/io/fs/
- latchkey 6y agoReading the API, I wonder how they plan to cancel long running (blocking) tasks, like WalkDir.
- collinvandyck76 6y agoSince there's no context in the API, you'd probably just need to use a WalkDirFunc with a closure that can reach the context. Awkward for sure.
- latchkey 6y agoI was referring to io outside of the WalkDirFunc. ;-)
- jitl 6y agoInstantiate the FS with a context, instead of requiring a context for each kind of FS operation.