Closed temoto closed 7 years ago
The signature IsDir() (bool, error)
is not idiomatic - Is*
commands should return bool
without error
part. Can we find a better name for this? AFAIR this was the main reason why this method is private. 🤔
@ppknap I'm confused. IsDir
should return bool
, but isDir
can return anything else?
We did know that IsDir() (bool, error)
is a bad function signature. Thus, we left it unexported so we won't introduce breaking API changes if we come up with a better name.
How about IsDirError
?
Hey @temoto, it is not about the naming but rather API surface. The goal here is to keep notify.EventInfo
interface possibly small (meaning also interface upgrades).
What I think would fit nice is:
type Stater interface {
Stat() (os.FileInfo, error)
}
And then some notify.fileInfo struct that will implement os.FileInfo - and set notify.fileInfo.isDir to the desired bool value. From os.FileInfo methods that we're unable to provide meaningful values, just return zero ones + proper inline documentation.
Another advantage besides better API would be possibility to just return os.FileInfo for those watcher implementations that do os.Stat either way (kqueue, future poller).
If you'd want to take try at that you may update this PR or start a new one.
Thank you. I only care about linux target and happy with fork.
https://github.com/rjeczalik/notify/issues/100