Skip to content

Commit

Permalink
Skips symlinks when walking files in a dir
Browse files Browse the repository at this point in the history
  • Loading branch information
dcarney authored and dcarney-stripe committed Dec 20, 2018
1 parent c0b55c8 commit e3b99be
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmd/misspell/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func main() {

for _, filename := range args {
filepath.Walk(filename, func(path string, info os.FileInfo, err error) error {
if err == nil && !info.IsDir() {
if err == nil && !info.IsDir() && !isSymlink(info) {
c <- path
}
return nil
Expand All @@ -324,3 +324,8 @@ func main() {
os.Exit(2)
}
}

// isSymlink returns true if info represents a symlink, false otherwise
func isSymlink(info os.FileInfo) bool {
return info.Mode()&os.ModeSymlink != 0
}

0 comments on commit e3b99be

Please sign in to comment.