typenative 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/README.md +17 -1
  3. package/bin/cli.js +25 -11
  4. package/bin/go/convert.js +11 -1
  5. package/bin/index.js +221 -44
  6. package/bin/main.js +35 -14
  7. package/bin/node/assert.js +2 -2
  8. package/bin/node/buffer.js +9 -0
  9. package/bin/node/dns.js +1 -1
  10. package/bin/node/events.js +1 -1
  11. package/bin/node/fs.js +1 -1
  12. package/bin/node/fs_watch.js +407 -0
  13. package/bin/node/http2.js +33 -6
  14. package/bin/node/readline.js +1 -1
  15. package/bin/node/registry.js +2 -1
  16. package/bin/node/stream.js +6 -3
  17. package/bin/node/timers.js +1 -1
  18. package/bin/node/tls.js +3 -1
  19. package/bin/node/typed_arrays.js +608 -0
  20. package/bin/node/util.js +3 -0
  21. package/bin/node/zlib.js +131 -16
  22. package/bin/transpiler.js +684 -62
  23. package/bin/version.js +1 -1
  24. package/conformance.md +16 -4
  25. package/examples/README.md +54 -0
  26. package/examples/fibonacci/README.md +89 -0
  27. package/examples/fibonacci/bench.mjs +87 -0
  28. package/examples/fibonacci/main.ts +21 -0
  29. package/examples/hello-world/README.md +62 -0
  30. package/examples/hello-world/bench.mjs +66 -0
  31. package/examples/hello-world/main.ts +7 -0
  32. package/examples/json-server/README.md +125 -0
  33. package/examples/json-server/bench.mjs +171 -0
  34. package/examples/json-server/main.ts +67 -0
  35. package/govendor/github.com/andybalholm/brotli/LICENSE +19 -0
  36. package/govendor/github.com/andybalholm/brotli/README.md +19 -0
  37. package/govendor/github.com/andybalholm/brotli/backward_references.go +185 -0
  38. package/govendor/github.com/andybalholm/brotli/backward_references_hq.go +796 -0
  39. package/govendor/github.com/andybalholm/brotli/bit_cost.go +436 -0
  40. package/govendor/github.com/andybalholm/brotli/bit_reader.go +266 -0
  41. package/govendor/github.com/andybalholm/brotli/bitwriter.go +56 -0
  42. package/govendor/github.com/andybalholm/brotli/block_splitter.go +144 -0
  43. package/govendor/github.com/andybalholm/brotli/block_splitter_command.go +434 -0
  44. package/govendor/github.com/andybalholm/brotli/block_splitter_distance.go +433 -0
  45. package/govendor/github.com/andybalholm/brotli/block_splitter_literal.go +433 -0
  46. package/govendor/github.com/andybalholm/brotli/brotli_bit_stream.go +1435 -0
  47. package/govendor/github.com/andybalholm/brotli/cluster.go +30 -0
  48. package/govendor/github.com/andybalholm/brotli/cluster_command.go +164 -0
  49. package/govendor/github.com/andybalholm/brotli/cluster_distance.go +326 -0
  50. package/govendor/github.com/andybalholm/brotli/cluster_literal.go +326 -0
  51. package/govendor/github.com/andybalholm/brotli/command.go +254 -0
  52. package/govendor/github.com/andybalholm/brotli/compress_fragment.go +834 -0
  53. package/govendor/github.com/andybalholm/brotli/compress_fragment_two_pass.go +775 -0
  54. package/govendor/github.com/andybalholm/brotli/constants.go +77 -0
  55. package/govendor/github.com/andybalholm/brotli/context.go +2176 -0
  56. package/govendor/github.com/andybalholm/brotli/decode.go +2570 -0
  57. package/govendor/github.com/andybalholm/brotli/dictionary.go +122890 -0
  58. package/govendor/github.com/andybalholm/brotli/dictionary_hash.go +32779 -0
  59. package/govendor/github.com/andybalholm/brotli/encode.go +1220 -0
  60. package/govendor/github.com/andybalholm/brotli/encoder.go +177 -0
  61. package/govendor/github.com/andybalholm/brotli/encoder_dict.go +22 -0
  62. package/govendor/github.com/andybalholm/brotli/encoder_fast.go +201 -0
  63. package/govendor/github.com/andybalholm/brotli/entropy_encode.go +592 -0
  64. package/govendor/github.com/andybalholm/brotli/entropy_encode_static.go +4399 -0
  65. package/govendor/github.com/andybalholm/brotli/fast_log.go +290 -0
  66. package/govendor/github.com/andybalholm/brotli/find_match_length.go +45 -0
  67. package/govendor/github.com/andybalholm/brotli/go.mod +3 -0
  68. package/govendor/github.com/andybalholm/brotli/h10.go +287 -0
  69. package/govendor/github.com/andybalholm/brotli/h5.go +214 -0
  70. package/govendor/github.com/andybalholm/brotli/h6.go +216 -0
  71. package/govendor/github.com/andybalholm/brotli/hash.go +342 -0
  72. package/govendor/github.com/andybalholm/brotli/hash_composite.go +93 -0
  73. package/govendor/github.com/andybalholm/brotli/hash_forgetful_chain.go +252 -0
  74. package/govendor/github.com/andybalholm/brotli/hash_longest_match_quickly.go +214 -0
  75. package/govendor/github.com/andybalholm/brotli/hash_rolling.go +168 -0
  76. package/govendor/github.com/andybalholm/brotli/histogram.go +226 -0
  77. package/govendor/github.com/andybalholm/brotli/http.go +201 -0
  78. package/govendor/github.com/andybalholm/brotli/huffman.go +653 -0
  79. package/govendor/github.com/andybalholm/brotli/literal_cost.go +182 -0
  80. package/govendor/github.com/andybalholm/brotli/matchfinder/bargain1.go +212 -0
  81. package/govendor/github.com/andybalholm/brotli/matchfinder/bargain2.go +248 -0
  82. package/govendor/github.com/andybalholm/brotli/matchfinder/bargain3.go +278 -0
  83. package/govendor/github.com/andybalholm/brotli/matchfinder/emitter.go +34 -0
  84. package/govendor/github.com/andybalholm/brotli/matchfinder/m0.go +175 -0
  85. package/govendor/github.com/andybalholm/brotli/matchfinder/m4.go +339 -0
  86. package/govendor/github.com/andybalholm/brotli/matchfinder/matchfinder.go +103 -0
  87. package/govendor/github.com/andybalholm/brotli/matchfinder/pathfinder.go +328 -0
  88. package/govendor/github.com/andybalholm/brotli/matchfinder/textencoder.go +53 -0
  89. package/govendor/github.com/andybalholm/brotli/matchfinder/trio.go +327 -0
  90. package/govendor/github.com/andybalholm/brotli/matchfinder/zdfast.go +258 -0
  91. package/govendor/github.com/andybalholm/brotli/matchfinder/zfast.go +206 -0
  92. package/govendor/github.com/andybalholm/brotli/matchfinder/zm.go +302 -0
  93. package/govendor/github.com/andybalholm/brotli/memory.go +66 -0
  94. package/govendor/github.com/andybalholm/brotli/metablock.go +574 -0
  95. package/govendor/github.com/andybalholm/brotli/metablock_command.go +165 -0
  96. package/govendor/github.com/andybalholm/brotli/metablock_distance.go +165 -0
  97. package/govendor/github.com/andybalholm/brotli/metablock_literal.go +165 -0
  98. package/govendor/github.com/andybalholm/brotli/params.go +37 -0
  99. package/govendor/github.com/andybalholm/brotli/platform.go +103 -0
  100. package/govendor/github.com/andybalholm/brotli/prefix.go +30 -0
  101. package/govendor/github.com/andybalholm/brotli/prefix_dec.go +723 -0
  102. package/govendor/github.com/andybalholm/brotli/quality.go +196 -0
  103. package/govendor/github.com/andybalholm/brotli/reader.go +127 -0
  104. package/govendor/github.com/andybalholm/brotli/ringbuffer.go +134 -0
  105. package/govendor/github.com/andybalholm/brotli/state.go +313 -0
  106. package/govendor/github.com/andybalholm/brotli/static_dict.go +662 -0
  107. package/govendor/github.com/andybalholm/brotli/static_dict_lut.go +75094 -0
  108. package/govendor/github.com/andybalholm/brotli/symbol_list.go +22 -0
  109. package/govendor/github.com/andybalholm/brotli/transform.go +641 -0
  110. package/govendor/github.com/andybalholm/brotli/utf8_util.go +70 -0
  111. package/govendor/github.com/andybalholm/brotli/util.go +7 -0
  112. package/govendor/github.com/andybalholm/brotli/write_bits.go +52 -0
  113. package/govendor/github.com/andybalholm/brotli/writer.go +162 -0
  114. package/govendor/github.com/fsnotify/fsnotify/.mailmap +2 -0
  115. package/govendor/github.com/fsnotify/fsnotify/CHANGELOG.md +651 -0
  116. package/govendor/github.com/fsnotify/fsnotify/CONTRIBUTING.md +147 -0
  117. package/govendor/github.com/fsnotify/fsnotify/LICENSE +25 -0
  118. package/govendor/github.com/fsnotify/fsnotify/README.md +214 -0
  119. package/govendor/github.com/fsnotify/fsnotify/backend_fen.go +469 -0
  120. package/govendor/github.com/fsnotify/fsnotify/backend_inotify.go +597 -0
  121. package/govendor/github.com/fsnotify/fsnotify/backend_kqueue.go +735 -0
  122. package/govendor/github.com/fsnotify/fsnotify/backend_other.go +22 -0
  123. package/govendor/github.com/fsnotify/fsnotify/backend_windows.go +702 -0
  124. package/govendor/github.com/fsnotify/fsnotify/fsnotify.go +526 -0
  125. package/govendor/github.com/fsnotify/fsnotify/go.mod +3 -0
  126. package/govendor/github.com/fsnotify/fsnotify/internal/darwin.go +20 -0
  127. package/govendor/github.com/fsnotify/fsnotify/internal/debug_darwin.go +15 -0
  128. package/govendor/github.com/fsnotify/fsnotify/internal/debug_dragonfly.go +15 -0
  129. package/govendor/github.com/fsnotify/fsnotify/internal/debug_freebsd.go +20 -0
  130. package/govendor/github.com/fsnotify/fsnotify/internal/debug_kqueue.go +32 -0
  131. package/govendor/github.com/fsnotify/fsnotify/internal/debug_linux.go +56 -0
  132. package/govendor/github.com/fsnotify/fsnotify/internal/debug_netbsd.go +15 -0
  133. package/govendor/github.com/fsnotify/fsnotify/internal/debug_openbsd.go +16 -0
  134. package/govendor/github.com/fsnotify/fsnotify/internal/debug_solaris.go +45 -0
  135. package/govendor/github.com/fsnotify/fsnotify/internal/debug_windows.go +40 -0
  136. package/govendor/github.com/fsnotify/fsnotify/internal/freebsd.go +20 -0
  137. package/govendor/github.com/fsnotify/fsnotify/internal/internal.go +2 -0
  138. package/govendor/github.com/fsnotify/fsnotify/internal/unix.go +20 -0
  139. package/govendor/github.com/fsnotify/fsnotify/internal/unix2.go +25 -0
  140. package/govendor/github.com/fsnotify/fsnotify/internal/windows.go +40 -0
  141. package/govendor/github.com/fsnotify/fsnotify/shared.go +64 -0
  142. package/govendor/github.com/fsnotify/fsnotify/staticcheck.conf +3 -0
  143. package/govendor/github.com/fsnotify/fsnotify/system_bsd.go +7 -0
  144. package/govendor/github.com/fsnotify/fsnotify/system_darwin.go +8 -0
  145. package/govendor/manifest.txt +3 -1
  146. package/package.json +1 -1
  147. package/types/typenative-npm.d.ts +72 -0
  148. package/types/typenative.d.ts +117 -1
@@ -0,0 +1,147 @@
1
+ Thank you for your interest in contributing to fsnotify! We try to review and
2
+ merge PRs in a reasonable timeframe, but please be aware that:
3
+
4
+ - To avoid "wasted" work, please discuss changes on the issue tracker first. You
5
+ can just send PRs, but they may end up being rejected for one reason or the
6
+ other.
7
+
8
+ - fsnotify is a cross-platform library, and changes must work reasonably well on
9
+ all supported platforms.
10
+
11
+ - Changes will need to be compatible; old code should still compile, and the
12
+ runtime behaviour can't change in ways that are likely to lead to problems for
13
+ users.
14
+
15
+ Testing
16
+ -------
17
+ Just `go test ./...` runs all the tests; the CI runs this on all supported
18
+ platforms. Testing different platforms locally can be done with something like
19
+ [goon] or [Vagrant], but this isn't super-easy to set up at the moment.
20
+
21
+ Use the `-short` flag to make the "stress test" run faster.
22
+
23
+ Writing new tests
24
+ -----------------
25
+ Scripts in the testdata directory allow creating test cases in a "shell-like"
26
+ syntax. The basic format is:
27
+
28
+ script
29
+
30
+ Output:
31
+ desired output
32
+
33
+ For example:
34
+
35
+ # Create a new empty file with some data.
36
+ watch /
37
+ echo data >/file
38
+
39
+ Output:
40
+ create /file
41
+ write /file
42
+
43
+ Just create a new file to add a new test; select which tests to run with
44
+ `-run TestScript/[path]`.
45
+
46
+ script
47
+ ------
48
+ The script is a "shell-like" script:
49
+
50
+ cmd arg arg
51
+
52
+ Comments are supported with `#`:
53
+
54
+ # Comment
55
+ cmd arg arg # Comment
56
+
57
+ All operations are done in a temp directory; a path like "/foo" is rewritten to
58
+ "/tmp/TestFoo/foo".
59
+
60
+ Arguments can be quoted with `"` or `'`; there are no escapes and they're
61
+ functionally identical right now, but this may change in the future, so best to
62
+ assume shell-like rules.
63
+
64
+ touch "/file with spaces"
65
+
66
+ End-of-line escapes with `\` are not supported.
67
+
68
+ ### Supported commands
69
+
70
+ watch path [ops] # Watch the path, reporting events for it. Nothing is
71
+ # watched by default. Optionally a list of ops can be
72
+ # given, as with AddWith(path, WithOps(...)).
73
+ unwatch path # Stop watching the path.
74
+ watchlist n # Assert watchlist length.
75
+
76
+ stop # Stop running the script; for debugging.
77
+ debug [yes/no] # Enable/disable FSNOTIFY_DEBUG (tests are run in
78
+ parallel by default, so -parallel=1 is probably a good
79
+ idea).
80
+ state # Print internal state to stderr (exact output differs
81
+ # per backend).
82
+ print [any strings] # Print text to stdout; for debugging.
83
+
84
+ touch path
85
+ mkdir [-p] dir
86
+ ln -s target link # Only ln -s supported.
87
+ mkfifo path
88
+ mknod dev path
89
+ mv src dst
90
+ rm [-r] path
91
+ chmod mode path # Octal only
92
+ sleep time-in-ms
93
+
94
+ cat path # Read path (does nothing with the data; just reads it).
95
+ echo str >>path # Append "str" to "path".
96
+ echo str >path # Truncate "path" and write "str".
97
+
98
+ require reason # Skip the test if "reason" is true; "skip" and
99
+ skip reason # "require" behave identical; it supports both for
100
+ # readability. Possible reasons are:
101
+ #
102
+ # always Always skip this test.
103
+ # symlink Symlinks are supported (requires admin
104
+ # permissions on Windows).
105
+ # mkfifo Platform doesn't support FIFO named sockets.
106
+ # mknod Platform doesn't support device nodes.
107
+
108
+
109
+ output
110
+ ------
111
+ After `Output:` the desired output is given; this is indented by convention, but
112
+ that's not required.
113
+
114
+ The format of that is:
115
+
116
+ # Comment
117
+ event path # Comment
118
+
119
+ system:
120
+ event path
121
+ system2:
122
+ event path
123
+
124
+ Every event is one line, and any whitespace between the event and path are
125
+ ignored. The path can optionally be surrounded in ". Anything after a "#" is
126
+ ignored.
127
+
128
+ Platform-specific tests can be added after GOOS; for example:
129
+
130
+ watch /
131
+ touch /file
132
+
133
+ Output:
134
+ # Tested if nothing else matches
135
+ create /file
136
+
137
+ # Windows-specific test.
138
+ windows:
139
+ write /file
140
+
141
+ You can specify multiple platforms with a comma (e.g. "windows, linux:").
142
+ "kqueue" is a shortcut for all kqueue systems (BSD, macOS).
143
+
144
+
145
+ [goon]: https://github.com/arp242/goon
146
+ [Vagrant]: https://www.vagrantup.com/
147
+ [integration_test.go]: /integration_test.go
@@ -0,0 +1,25 @@
1
+ Copyright © 2012 The Go Authors. All rights reserved.
2
+ Copyright © fsnotify Authors. All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice, this
10
+ list of conditions and the following disclaimer in the documentation and/or
11
+ other materials provided with the distribution.
12
+ * Neither the name of Google Inc. nor the names of its contributors may be used
13
+ to endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,214 @@
1
+ fsnotify is a Go library to provide cross-platform filesystem notifications on
2
+ Windows, Linux, macOS, BSD, and illumos.
3
+
4
+ Go 1.23 or newer is required; the full documentation is at
5
+ https://pkg.go.dev/github.com/fsnotify/fsnotify
6
+
7
+ ---
8
+
9
+ Platform support:
10
+
11
+ | Backend | OS | Status |
12
+ | :-------------------- | :--------- | :------------------------------------------------------------------------ |
13
+ | inotify | Linux | Supported |
14
+ | kqueue | BSD, macOS | Supported |
15
+ | ReadDirectoryChangesW | Windows | Supported ([excluding `Chmod` operations][#487]) |
16
+ | FEN | illumos | Supported |
17
+ | fanotify | Linux 5.9+ | [Not yet](https://github.com/fsnotify/fsnotify/issues/114) |
18
+ | FSEvents | macOS | [Needs support in x/sys/unix][fsevents] |
19
+ | USN Journals | Windows | [Needs support in x/sys/windows][usn] |
20
+ | Polling | *All* | [Not yet](https://github.com/fsnotify/fsnotify/issues/9) |
21
+
22
+ Linux and illumos should include Android and Solaris, but these are currently
23
+ untested.
24
+
25
+ [#487]: https://github.com/fsnotify/fsnotify/issues/487
26
+ [fsevents]: https://github.com/fsnotify/fsnotify/issues/11#issuecomment-1279133120
27
+ [usn]: https://github.com/fsnotify/fsnotify/issues/53#issuecomment-1279829847
28
+
29
+ Usage
30
+ -----
31
+ A basic example:
32
+
33
+ ```go
34
+ package main
35
+
36
+ import (
37
+ "log"
38
+
39
+ "github.com/fsnotify/fsnotify"
40
+ )
41
+
42
+ func main() {
43
+ // Create new watcher.
44
+ watcher, err := fsnotify.NewWatcher()
45
+ if err != nil {
46
+ log.Fatal(err)
47
+ }
48
+ defer watcher.Close()
49
+
50
+ // Start listening for events.
51
+ go func() {
52
+ for {
53
+ select {
54
+ case event, ok := <-watcher.Events:
55
+ if !ok {
56
+ return
57
+ }
58
+ log.Println("event:", event)
59
+ if event.Has(fsnotify.Write) {
60
+ log.Println("modified file:", event.Name)
61
+ }
62
+ case err, ok := <-watcher.Errors:
63
+ if !ok {
64
+ return
65
+ }
66
+ log.Println("error:", err)
67
+ }
68
+ }
69
+ }()
70
+
71
+ // Add a path.
72
+ err = watcher.Add("/tmp")
73
+ if err != nil {
74
+ log.Fatal(err)
75
+ }
76
+
77
+ // Block main goroutine forever.
78
+ <-make(chan struct{})
79
+ }
80
+ ```
81
+
82
+ Some more examples can be found in [cmd/fsnotify](cmd/fsnotify), which can be
83
+ run with:
84
+
85
+ % go run ./cmd/fsnotify
86
+
87
+ Further detailed documentation can be found in godoc:
88
+ https://pkg.go.dev/github.com/fsnotify/fsnotify
89
+
90
+ FAQ
91
+ ---
92
+ ### Will a file still be watched when it's moved to another directory?
93
+ No, not unless you are watching the location it was moved to.
94
+
95
+ ### Are subdirectories watched?
96
+ No, you must add watches for any directory you want to watch (a recursive
97
+ watcher is on the roadmap: [#18]).
98
+
99
+ [#18]: https://github.com/fsnotify/fsnotify/issues/18
100
+
101
+ ### Do I have to watch the Error and Event channels in a goroutine?
102
+ Yes. You can read both channels in the same goroutine using `select` (you don't
103
+ need a separate goroutine for both channels; see the example).
104
+
105
+ ### Why don't notifications work with NFS, SMB, FUSE, /proc, or /sys?
106
+ fsnotify requires support from underlying OS to work. The current NFS and SMB
107
+ protocols does not provide network level support for file notifications, and
108
+ neither do the /proc and /sys virtual filesystems.
109
+
110
+ This could be fixed with a polling watcher ([#9]), but it's not yet implemented.
111
+
112
+ [#9]: https://github.com/fsnotify/fsnotify/issues/9
113
+
114
+ ### Why do I get many Chmod events?
115
+ Some programs may generate a lot of attribute changes; for example Spotlight on
116
+ macOS, anti-virus programs, backup applications, and some others are known to do
117
+ this. As a rule, it's typically best to ignore Chmod events. They're often not
118
+ useful, and tend to cause problems.
119
+
120
+ Spotlight indexing on macOS can result in multiple events (see [#15]). A
121
+ temporary workaround is to add your folder(s) to the *Spotlight Privacy
122
+ settings* until we have a native FSEvents implementation (see [#11]).
123
+
124
+ [#11]: https://github.com/fsnotify/fsnotify/issues/11
125
+ [#15]: https://github.com/fsnotify/fsnotify/issues/15
126
+
127
+ ### Watching a file doesn't work well
128
+ Watching individual files (rather than directories) is generally not recommended
129
+ as many programs (especially editors) update files atomically: it will write to
130
+ a temporary file which is then moved to a destination, overwriting the original
131
+ (or some variant thereof). The watcher on the original file is now lost, as that
132
+ no longer exists.
133
+
134
+ The upshot of this is that a power failure or crash won't leave a half-written
135
+ file.
136
+
137
+ Watch the parent directory and use `Event.Name` to filter out files you're not
138
+ interested in. There is an example of this in `cmd/fsnotify/file.go`.
139
+
140
+ Platform-specific notes
141
+ -----------------------
142
+ ### Linux
143
+ When a file is removed a REMOVE event won't be emitted until all file
144
+ descriptors are closed; it will emit a CHMOD instead:
145
+
146
+ fp := os.Open("file")
147
+ os.Remove("file") // CHMOD
148
+ fp.Close() // REMOVE
149
+
150
+ This is the event that inotify sends, so not much can be changed about this.
151
+
152
+ The `fs.inotify.max_user_watches` sysctl variable specifies the upper limit for
153
+ the number of watches per user, and `fs.inotify.max_user_instances` specifies
154
+ the maximum number of inotify instances per user. Every Watcher you create is an
155
+ "instance", and every path you add is a "watch". Reaching the limit will result
156
+ in a "no space left on device" or "too many open files" error.
157
+
158
+ These are also exposed in `/proc` as `/proc/sys/fs/inotify/max_user_watches` and
159
+ `/proc/sys/fs/inotify/max_user_instances`. The default values differ per distro
160
+ and available memory.
161
+
162
+ To increase them you can use `sysctl` or write the value to proc file:
163
+
164
+ sysctl fs.inotify.max_user_watches=200000
165
+ sysctl fs.inotify.max_user_instances=256
166
+
167
+ To make the changes persist on reboot edit `/etc/sysctl.conf` or
168
+ `/usr/lib/sysctl.d/50-default.conf` (details differ per Linux distro; check your
169
+ distro's documentation):
170
+
171
+ fs.inotify.max_user_watches=200000
172
+ fs.inotify.max_user_instances=256
173
+
174
+ ### Windows
175
+ Recursive watching is not currently enabled through fsnotify's public API
176
+ (see the FAQ "Are subdirectories watched?" above). The notes below
177
+ describe Windows backend behavior observed when recursive watching is
178
+ enabled internally (for example, in fsnotify's own tests). They are kept
179
+ here as a reference for maintainers and contributors who encounter the
180
+ behavior, since the recursive code path still exists in the backend.
181
+
182
+ When recursive watching is enabled and you watch a directory, you may
183
+ receive a `Write` event for an intermediate directory whenever a child
184
+ entry inside it is created, renamed, or removed. For example, with a
185
+ recursive watch on `/a` and a new file `/a/b/c`, you will receive
186
+ `Create /a/b/c` and may also receive `Write /a/b`.
187
+
188
+ This happens because, on NTFS-backed volumes, modifying the entries of a
189
+ directory updates that directory's last-write time, and the Windows
190
+ backend requests `FILE_NOTIFY_CHANGE_LAST_WRITE` to support `Write` events
191
+ on files. The same `Write` filter therefore picks up the directory's
192
+ metadata update.
193
+
194
+ kqueue has the same "directory `Write` = directory contents changed"
195
+ semantics, so portable code that treats `Write` on a directory as
196
+ "something inside it changed" works on Windows and BSD/macOS, but not on
197
+ Linux (inotify uses `Write` only for file-content changes). If you only
198
+ care about file content, filter out `Write` events whose path refers to a
199
+ directory.
200
+
201
+ Whether the directory `Write` is actually delivered alongside the child
202
+ events is not guaranteed: it depends on `ReadDirectoryChangesW` buffering,
203
+ NTFS metadata update timing, and event coalescing, none of which fsnotify
204
+ controls.
205
+
206
+
207
+ ### kqueue (macOS, all BSD systems)
208
+ kqueue requires opening a file descriptor for every file that's being watched;
209
+ so if you're watching a directory with five files then that's six file
210
+ descriptors. You will run in to your system's "max open files" limit faster on
211
+ these platforms.
212
+
213
+ The sysctl variables `kern.maxfiles` and `kern.maxfilesperproc` can be used to
214
+ control the maximum number of open files.