Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

Commit e3b99be

Browse files
dcarneydcarney-stripe
authored andcommitted
Skips symlinks when walking files in a dir
1 parent c0b55c8 commit e3b99be

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cmd/misspell/main.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ func main() {
301301

302302
for _, filename := range args {
303303
filepath.Walk(filename, func(path string, info os.FileInfo, err error) error {
304-
if err == nil && !info.IsDir() {
304+
if err == nil && !info.IsDir() && !isSymlink(info) {
305305
c <- path
306306
}
307307
return nil
@@ -324,3 +324,8 @@ func main() {
324324
os.Exit(2)
325325
}
326326
}
327+
328+
// isSymlink returns true if info represents a symlink, false otherwise
329+
func isSymlink(info os.FileInfo) bool {
330+
return info.Mode()&os.ModeSymlink != 0
331+
}

0 commit comments

Comments
 (0)