Last active
March 6, 2019 02:10
-
-
Save rustysys-dev/bfe6abb322fceddd721a1598a6645cf7 to your computer and use it in GitHub Desktop.
Find all dirs in given directory.
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 ( | |
"flag" | |
"fmt" | |
"os" | |
"path/filepath" | |
"regexp" | |
) | |
func visit(path string, f os.FileInfo, err error) error { | |
r, _ := regexp.Compile(`(^.*/\..*$)`) | |
if f.IsDir() { | |
match := r.MatchString(path) | |
if match != true { | |
fmt.Printf("%s\n", path) | |
return nil | |
} | |
} | |
return nil | |
} | |
func main() { | |
flag.Parse() | |
root := flag.Arg(0) | |
err := filepath.Walk(root, visit) | |
if err != nil { | |
fmt.Printf("filepath.Walk() returned %v\n", err) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment