[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-5032":3},{"id":4,"name":5,"fullName":6,"owner":5,"repo":5,"description":7,"homepage":8,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":15,"forks30d":15,"starsTrendScore":19,"compositeScore":20,"rankGlobal":9,"rankLanguage":9,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":22,"hasPages":22,"topics":24,"createdAt":9,"pushedAt":9,"updatedAt":25,"readmeContent":26,"aiSummary":27,"trendingCount":15,"starSnapshotCount":15,"syncStatus":16,"lastSyncTime":28,"discoverSource":29},5032,"fsnotify","fsnotify\u002Ffsnotify","Cross-platform filesystem notifications for Go.","",null,"Go",10725,974,139,27,0,2,9,52,7,82.67,"BSD 3-Clause \"New\" or \"Revised\" License",false,"main",[],"2026-06-13 04:00:23","fsnotify is a Go library to provide cross-platform filesystem notifications on\nWindows, Linux, macOS, BSD, and illumos.\n\nGo 1.23 or newer is required; the full documentation is at\nhttps:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Ffsnotify\u002Ffsnotify\n\n---\n\nPlatform support:\n\n| Backend               | OS         | Status                                                                    |\n| :-------------------- | :--------- | :------------------------------------------------------------------------ |\n| inotify               | Linux      | Supported                                                                 |\n| kqueue                | BSD, macOS | Supported                                                                 |\n| ReadDirectoryChangesW | Windows    | Supported                                                                 |\n| FEN                   | illumos    | Supported                                                                 |\n| fanotify              | Linux 5.9+ | [Not yet](https:\u002F\u002Fgithub.com\u002Ffsnotify\u002Ffsnotify\u002Fissues\u002F114)                |\n| FSEvents              | macOS      | [Needs support in x\u002Fsys\u002Funix][fsevents]                                   |\n| USN Journals          | Windows    | [Needs support in x\u002Fsys\u002Fwindows][usn]                                     |\n| Polling               | *All*      | [Not yet](https:\u002F\u002Fgithub.com\u002Ffsnotify\u002Ffsnotify\u002Fissues\u002F9)                  |\n\nLinux and illumos should include Android and Solaris, but these are currently\nuntested.\n\n[fsevents]: https:\u002F\u002Fgithub.com\u002Ffsnotify\u002Ffsnotify\u002Fissues\u002F11#issuecomment-1279133120\n[usn]:      https:\u002F\u002Fgithub.com\u002Ffsnotify\u002Ffsnotify\u002Fissues\u002F53#issuecomment-1279829847\n\nUsage\n-----\nA basic example:\n\n```go\npackage main\n\nimport (\n    \"log\"\n\n    \"github.com\u002Ffsnotify\u002Ffsnotify\"\n)\n\nfunc main() {\n    \u002F\u002F Create new watcher.\n    watcher, err := fsnotify.NewWatcher()\n    if err != nil {\n        log.Fatal(err)\n    }\n    defer watcher.Close()\n\n    \u002F\u002F Start listening for events.\n    go func() {\n        for {\n            select {\n            case event, ok := \u003C-watcher.Events:\n                if !ok {\n                    return\n                }\n                log.Println(\"event:\", event)\n                if event.Has(fsnotify.Write) {\n                    log.Println(\"modified file:\", event.Name)\n                }\n            case err, ok := \u003C-watcher.Errors:\n                if !ok {\n                    return\n                }\n                log.Println(\"error:\", err)\n            }\n        }\n    }()\n\n    \u002F\u002F Add a path.\n    err = watcher.Add(\"\u002Ftmp\")\n    if err != nil {\n        log.Fatal(err)\n    }\n\n    \u002F\u002F Block main goroutine forever.\n    \u003C-make(chan struct{})\n}\n```\n\nSome more examples can be found in [cmd\u002Ffsnotify](cmd\u002Ffsnotify), which can be\nrun with:\n\n    % go run .\u002Fcmd\u002Ffsnotify\n\nFurther detailed documentation can be found in godoc:\nhttps:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Ffsnotify\u002Ffsnotify\n\nFAQ\n---\n### Will a file still be watched when it's moved to another directory?\nNo, not unless you are watching the location it was moved to.\n\n### Are subdirectories watched?\nNo, you must add watches for any directory you want to watch (a recursive\nwatcher is on the roadmap: [#18]).\n\n[#18]: https:\u002F\u002Fgithub.com\u002Ffsnotify\u002Ffsnotify\u002Fissues\u002F18\n\n### Do I have to watch the Error and Event channels in a goroutine?\nYes. You can read both channels in the same goroutine using `select` (you don't\nneed a separate goroutine for both channels; see the example).\n\n### Why don't notifications work with NFS, SMB, FUSE, \u002Fproc, or \u002Fsys?\nfsnotify requires support from underlying OS to work. The current NFS and SMB\nprotocols does not provide network level support for file notifications, and\nneither do the \u002Fproc and \u002Fsys virtual filesystems.\n\nThis could be fixed with a polling watcher ([#9]), but it's not yet implemented.\n\n[#9]: https:\u002F\u002Fgithub.com\u002Ffsnotify\u002Ffsnotify\u002Fissues\u002F9\n\n### Why do I get many Chmod events?\nSome programs may generate a lot of attribute changes; for example Spotlight on\nmacOS, anti-virus programs, backup applications, and some others are known to do\nthis. As a rule, it's typically best to ignore Chmod events. They're often not\nuseful, and tend to cause problems.\n\nSpotlight indexing on macOS can result in multiple events (see [#15]). A\ntemporary workaround is to add your folder(s) to the *Spotlight Privacy\nsettings* until we have a native FSEvents implementation (see [#11]).\n\n[#11]: https:\u002F\u002Fgithub.com\u002Ffsnotify\u002Ffsnotify\u002Fissues\u002F11\n[#15]: https:\u002F\u002Fgithub.com\u002Ffsnotify\u002Ffsnotify\u002Fissues\u002F15\n\n### Watching a file doesn't work well\nWatching individual files (rather than directories) is generally not recommended\nas many programs (especially editors) update files atomically: it will write to\na temporary file which is then moved to a destination, overwriting the original\n(or some variant thereof). The watcher on the original file is now lost, as that\nno longer exists.\n\nThe upshot of this is that a power failure or crash won't leave a half-written\nfile.\n\nWatch the parent directory and use `Event.Name` to filter out files you're not\ninterested in. There is an example of this in `cmd\u002Ffsnotify\u002Ffile.go`.\n\nPlatform-specific notes\n-----------------------\n### Linux\nWhen a file is removed a REMOVE event won't be emitted until all file\ndescriptors are closed; it will emit a CHMOD instead:\n\n    fp := os.Open(\"file\")\n    os.Remove(\"file\")        \u002F\u002F CHMOD\n    fp.Close()               \u002F\u002F REMOVE\n\nThis is the event that inotify sends, so not much can be changed about this.\n\nThe `fs.inotify.max_user_watches` sysctl variable specifies the upper limit for\nthe number of watches per user, and `fs.inotify.max_user_instances` specifies\nthe maximum number of inotify instances per user. Every Watcher you create is an\n\"instance\", and every path you add is a \"watch\". Reaching the limit will result\nin a \"no space left on device\" or \"too many open files\" error.\n\nThese are also exposed in `\u002Fproc` as `\u002Fproc\u002Fsys\u002Ffs\u002Finotify\u002Fmax_user_watches` and\n`\u002Fproc\u002Fsys\u002Ffs\u002Finotify\u002Fmax_user_instances`. The default values differ per distro\nand available memory.\n\nTo increase them you can use `sysctl` or write the value to proc file:\n\n    sysctl fs.inotify.max_user_watches=200000\n    sysctl fs.inotify.max_user_instances=256\n\nTo make the changes persist on reboot edit `\u002Fetc\u002Fsysctl.conf` or\n`\u002Fusr\u002Flib\u002Fsysctl.d\u002F50-default.conf` (details differ per Linux distro; check your\ndistro's documentation):\n\n    fs.inotify.max_user_watches=200000\n    fs.inotify.max_user_instances=256\n\n### kqueue (macOS, all BSD systems)\nkqueue requires opening a file descriptor for every file that's being watched;\nso if you're watching a directory with five files then that's six file\ndescriptors. You will run in to your system's \"max open files\" limit faster on\nthese platforms.\n\nThe sysctl variables `kern.maxfiles` and `kern.maxfilesperproc` can be used to\ncontrol the maximum number of open files.\n","fsnotify 是一个用于 Go 语言的跨平台文件系统通知库，支持 Windows、Linux、macOS、BSD 和 illumos 系统。其核心功能是实时监控文件或目录的变化事件，如创建、删除、修改等，并通过统一的接口提供给开发者使用，简化了不同操作系统下的开发工作。该库利用了多种后端技术来实现高效的文件监控，包括 inotify（Linux）、kqueue（BSD, macOS）和 ReadDirectoryChangesW（Windows）。适用于需要实时响应文件变化的应用场景，例如自动化构建工具、日志监控系统或者任何需要即时感知文件变动的软件解决方案中。","2026-06-11 03:02:11","top_language"]