Skip to content

Walk files of folder before recursing into sub-folders #67

Open
@shlomi-dr

Description

Is there a way with this library to first invoke the callback on all direct files under the current folder before recursing into the sub-folders?

Example:

package main

import (
	"fmt"
	"github.com/karrick/godirwalk"
)

func main() {
	godirwalk.Walk("/tmp/test", &godirwalk.Options{
		Callback: func(osPathname string, directoryEntry *godirwalk.Dirent) error {
			fmt.Printf("%s\n", osPathname)
			return nil
		}})
}

currently results in:

/tmp/test
/tmp/test/afile
/tmp/test/dir1
/tmp/test/dir1/file2
/tmp/test/file

and the ask is to return:

/tmp/test
/tmp/test/afile
/tmp/test/file
/tmp/test/dir1
/tmp/test/dir1/file2

This way the results are still deterministic as all files of current folder are sorted, and the sub-folders are recursed into also in a sorted order.

Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions