Hacker News new | ask | show | jobs
by kevlar1818 2014 days 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/

1 comments

Reading the API, I wonder how they plan to cancel long running (blocking) tasks, like WalkDir.
Instantiate the FS with a context, instead of requiring a context for each kind of FS operation.
Since 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.
I was referring to io outside of the WalkDirFunc. ;-)