This is a creation in Article, where the information may have evolved or changed.
with python it is convenient to traverse the folder, Go World, I also need such a function. Find the document, which has this function (for specific reference here:http://golang.org/pkg/path/filepath/ ) ...
OK, no nonsense, I also want to go to bed early, directly on the code.
The code is as follows:
/*File:getFilelist.goAuthor:mikee-mail:mike_zhang@live.com*/Package main Import ("Path/filepath" "OS" "FMT" "Flag" ) func getfilelist (path string) { err: = filepath. Walk (Path, func (path string , F OS. FileInfo, err error ) error {
if
( f = = Nil ) { return err} if f.isdir () {return nil} println(path) return nil }) if err! = nil { FMT. Printf ("filepath. Walk () returned%v\ n", err) } } func Main () {flag. Parse () Root: = flag. ARG (0) getfilelist (Root) }
The results are as follows:
All right, that's it, I hope it helps you.