Skip to content

Commit bfa0135

Browse files
authored
Allow build on unsupported GOOS (#424)
In cases where fsnotify is a transitive dependency of a package, it might need to be built on platforms not supported (yet), e.g. aix. Provide an empty implemention for these cases, so depending packages don't need to add workarounds. Replaces #314
1 parent c4cd7f3 commit bfa0135

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

fsnotify_unsupported.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright 2022 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
//go:build !darwin && !dragonfly && !freebsd && !linux && !netbsd && !solaris && !windows
6+
// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!solaris,!windows
7+
8+
package fsnotify
9+
10+
import (
11+
"fmt"
12+
"runtime"
13+
)
14+
15+
// Watcher watches a set of files, delivering events to a channel.
16+
type Watcher struct{}
17+
18+
// NewWatcher establishes a new watcher with the underlying OS and begins waiting for events.
19+
func NewWatcher() (*Watcher, error) {
20+
return nil, fmt.Errorf("fsnotify not supported on %s", runtime.GOOS)
21+
}
22+
23+
// Close removes all watches and closes the events channel.
24+
func (w *Watcher) Close() error {
25+
return nil
26+
}
27+
28+
// Add starts watching the named file or directory (non-recursively).
29+
func (w *Watcher) Add(name string) error {
30+
return nil
31+
}
32+
33+
// Remove stops watching the the named file or directory (non-recursively).
34+
func (w *Watcher) Remove(name string) error {
35+
return nil
36+
}

0 commit comments

Comments
 (0)