Skip to content

Inconsistent behavior of WatchList on Windows and Unix #609

@artiga033

Description

@artiga033

Describe the bug

The WatchList() function returns the exact file on linux, while the parent folder on Windows.

To Reproduce

package main

import (
	"fmt"
	"os"
	"path/filepath"

	"github.com/fsnotify/fsnotify"
)

func main() {
	watcher, _ := fsnotify.NewWatcher()
	defer watcher.Close()
	f, _ := filepath.Abs("test.txt")
	os.Create(f)
	watcher.Add(f)
	fmt.Printf("WatchList: %v\n", watcher.WatchList())
}
> go run .
WatchList: [F:\tmp\fsnotify_t]
> wsl go run .
WatchList: [/mnt/f/tmp/fsnotify_t/test.txt]

Which operating system and version are you using?

Windows 11 Professional 23H2 (22631.3374)
Arch Linux WSL (kernel 5.15)

Which fsnotify version are you using?

main branch

Did you try the latest main branch?

Yes

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