Here’s an iterator alternative to io/fs WalkDir:

    https://kr.dev/walk

Russ made an effort[1] to do something along these lines in the
standard library, and I guess folks weren’t able to reach consensus on
what it should look like. That’s understandable. But I still like the
iterator style, so here’s my take on it!

A while back[2] I did something similar with filepath.Walk. This new
one incorporates as much as I could out of the feedback from last
time. (Which I prolly should’ve done in the older one too. 😅)

    - SkipParent skips the rest of the directory containing the
current item. (Thanks for the suggestion Rog!)

    - The next method is called Next this time, not Step. (Thanks again Rog!)

Like the old kr/fs, kr.dev/walk tries to hew closely to how the
standard library works. There should be no big surprises, it’s just a
re-skin. (The only real difference I can see: in io/fs, SkipDir means
two different things depending on whether the current entry is a
directory, but in kr.dev/walk, we have SkipDir and SkipParent and each
always does the same thing.)

Right now v0.1.0 is tagged. I don’t foresee big changes. If a few days
pass without any, I’ll tag v1.0.0. I am tempted to steal some of the
interface changes Russ made in 41974. Especially Rel. Maybe replacing
Entry with its methods IsDir, Type, etc.

Thoughts?

[1] https://github.com/golang/go/issues/41974

[2] https://groups.google.com/g/golang-nuts/c/jmCfMnm7uy4/m/_TY3W_H2LfwJ

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAD25zGC5axp_8bhF0PM-N14423cx4tK8VSbM_gBae2icFjTS4Q%40mail.gmail.com.

Reply via email to