Skip to content

Instantly share code, notes, and snippets.

@magicianzrh
Created February 6, 2015 08:01
Show Gist options
  • Save magicianzrh/8867607c25937646ee8e to your computer and use it in GitHub Desktop.
Save magicianzrh/8867607c25937646ee8e to your computer and use it in GitHub Desktop.
func checkFolderFileName(p_path string) {
reg, err := regexp.Compile(`^[a-zA-Z0-9._/-]{1,100}$`)
if err != nil {
log.Fatal(err)
}
filepath.Walk(p_path, func(path string, fi os.FileInfo, err error) error {
if fi == nil {
return err
}
if fi.IsDir() {
return nil
}
if !reg.MatchString(fi.Name()) {
fmt.Println("file name err:" + fi.Name())
}
return nil
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment