Skip to content

Instantly share code, notes, and snippets.

@caojunxyz
caojunxyz / .go
Created September 8, 2019 15:11
Two methods of traverse directory with golang
func exclude(dir, path string) bool {
rel, _ := filepath.Rel(dir, path)
segs := strings.Split(rel, fmt.Sprintf("%c", os.PathSeparator))
if segs[0] == ".git" || segs[0] == ".idea" {
return true
}
name := filepath.Base(path)
if name == ".DS_Store" {
return true