package storage import ( "os" "path/filepath" ) type FileSystem struct { root string } func WalkFolder(folder string, walkMode WalkMode) <-chan string { c := make(chan string) go func(folder string, c chan string) { filepath.Walk(folder, func(path string, info os.FileInfo, err error) error { file, _ := os.Open(path) defer file.Close() fileInfo, _ := file.Stat() switch walkMode { case Folder: if fileInfo.IsDir() { c <- path } case File: if !fileInfo.IsDir() { c <- path } case FileFolder: c <- path } return nil }) close(c) }(folder, c) return c }