Skip to content

Add option to disable following symlinks #227

@adriansr

Description

@adriansr

Which operating system (GOOS) and version are you using?

GOOS: darwin
ProductName: Mac OS X
ProductVersion: 10.12.6
BuildVersion: 16G1036

Please describe the issue that occurred.

Under macOS, fsnotify follows symlinks on watched directories and produces notifications for changes to files residing on directories pointed by the symlink.

Are you able to reproduce the issue? Please provide steps to reproduce and a code sample if possible.

  1. The usual watcher / logger:
package main

import (
	"log"

	"github.com/fsnotify/fsnotify"
)

func main() {
	watcher, err := fsnotify.NewWatcher()
	if err != nil {
		log.Fatal(err)
	}
	defer watcher.Close()
	err = watcher.Add("/tmp/bug")
	if err != nil {
		log.Fatal(err)
	}
	for {
		select {
		case ev := <-watcher.Events:
			log.Printf("Got event %+v", ev)
		}
	}
}

Operations to perform:

mkdir /tmp/bug
mkdir /tmp/other
ln -s /tmp/other /tmp/bug/link
touch /tmp/other/somefile

Events received:

2017/12/11 23:44:38 Got event "/tmp/bug/link": CREATE
2017/12/11 23:44:41 Got event "/private/tmp/other/somefile": CREATE

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions