Documentation ¶
Overview ¶
Package watch implements file watching utilities.
1. This is not concerned with very large directories. 2. The focus is on simplicity for use in build tools. 3. Cross platform support would be abstracted into a singe API. 4. Context-aware Streams-based API.
Index ¶
- func Close(s Stream) error
- func Glob(pattern string) (allow func(path string) bool)
- func LastModifiedChecksum(path string) interface{}
- type Stream
- func CurrentDir(glob string) Stream
- func Dedup(checksum func(string) interface{}, s Stream) Stream
- func Delay(duration time.Duration, s Stream) Stream
- func Dir(dir string) Stream
- func DirSnap(root string) Stream
- func Error(err error) Stream
- func Filter(allow func(path string) bool, s Stream) Stream
- func Repeat(create func() Stream) Stream
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LastModifiedChecksum ¶
func LastModifiedChecksum(path string) interface{}
LastModifiedChecksum uses the last modified time as the checksum for a path.
Types ¶
type Stream ¶
Stream is the main interface implemented by various watchers.
It is the basis for composition (such as with Delay or Repeat or Filter).
func CurrentDir ¶
CurrentDir automatically picks the current dir but also filters by the glob pattern.
func Dedup ¶
Dedup drops duplicates in the stream.
Duplicates are identified by comparing the results of the checksum against previous results, if any.
If the checksum returns nil, the last checksum is uncached.
func Delay ¶
Delay waits for the specified time before allowing the first call to proceed. This is useful when combined with Repeat to setup a polling interval.
func DirSnap ¶
DirSnap snapshots a dir and returns all the current files via the Stream. It does not watch for changes after that, returning an io.EOF instead. NextPath must not be called after an EOF is returned.