Created
March 10, 2014 22:21
-
-
Save sethamclean/9475737 to your computer and use it in GitHub Desktop.
filepath.walk go routine generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"path/filepath" | |
"fmt" | |
"os" | |
) | |
func main(){ | |
location := "../gocode/" | |
chann := GoWalk(location) | |
for msg := range chann { | |
fmt.Println(msg) | |
} | |
return | |
} | |
func GoWalk(location string) (chan string) { | |
chann := make(chan string) | |
go func(){ | |
filepath.Walk(location, func(path string, _ os.FileInfo, _ error)(err error){ | |
chann <- path | |
return | |
}) | |
defer close(chann) | |
}() | |
return chann | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment