{"id":19397170,"url":"https://github.com/illarion/gonotify","last_synced_at":"2025-04-04T22:01:29.006Z","repository":{"id":57536627,"uuid":"133827069","full_name":"illarion/gonotify","owner":"illarion","description":"Inotify wrapper","archived":false,"fork":false,"pushed_at":"2024-10-11T10:05:21.000Z","size":56,"stargazers_count":33,"open_issues_count":2,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T21:01:32.234Z","etag":null,"topics":["events","file-system","inotify","inotify-wrapper","linux"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/illarion.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"illarion"}},"created_at":"2018-05-17T14:41:51.000Z","updated_at":"2025-03-10T01:21:04.000Z","dependencies_parsed_at":"2024-11-10T10:49:46.423Z","dependency_job_id":null,"html_url":"https://github.com/illarion/gonotify","commit_stats":{"total_commits":20,"total_committers":1,"mean_commits":20.0,"dds":0.0,"last_synced_commit":"85059bf2ec752cab50a108feb7125eb2d071d402"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/illarion%2Fgonotify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/illarion%2Fgonotify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/illarion%2Fgonotify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/illarion%2Fgonotify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/illarion","download_url":"https://codeload.github.com/illarion/gonotify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247256092,"owners_count":20909240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["events","file-system","inotify","inotify-wrapper","linux"],"created_at":"2024-11-10T10:39:42.196Z","updated_at":"2025-04-04T22:01:28.942Z","avatar_url":"https://github.com/illarion.png","language":"Go","funding_links":["https://github.com/sponsors/illarion"],"categories":[],"sub_categories":[],"readme":"## Gonotify \n\nSimple Golang inotify wrapper.\n\n[![GoDoc](https://godoc.org/github.com/illarion/gonotify/v3?status.svg)](https://godoc.org/github.com/illarion/gonotify/v3)\n\n### Provides following primitives:\n\n* Low level\n  * `Inotify` - wrapper around [inotify(7)](http://man7.org/linux/man-pages/man7/inotify.7.html)\n  * `InotifyEvent` - generated file/folder event. Contains `Name` (full path), `Wd` - watch descriptor and `Mask` that describes the event.\n\n* Higher level\n  * `FileWatcher` - higher level utility, helps to watch the list of files for changes, creation or removal\n  * `DirWatcher` - higher level utility, recursively watches given root folder for added, removed or changed files.\n  * `FileEvent` - embeds `InotifyEvent` and keeps additional field `Eof` to notify user that there will be no more events.\n\nUse `FileWatcher` and `DirWatcher` as an example and build your own utility classes.\n\n### Usage\n\n```go\npackage main\n\nimport (\n  \"fmt\"\n  \"github.com/illarion/gonotify/v3\"\n  \"time\"\n  \"context\"\n)\n\nfunc main() {\n\n  ctx, cancel := context.WithCancel(context.Background())\n\n  watcher, err := gonotify.NewDirWatcher(ctx, gonotify.IN_CREATE|gonotify.IN_CLOSE, \"/tmp\")\n  if err != nil {\n    panic(err)\n  }\n\n  main:\n  for {\n    select {\n    case event := \u003c-watcher.C:\n      fmt.Printf(\"Event: %s\\n\", event)\n\n      if event.Is(gonotify.IN_CREATE) {\n        fmt.Printf(\"File created: %s\\n\", event.Name)\n      }\n\n      if event.IsAny(gonotify.IN_CLOSE, gonotify.IN_CLOSE_WRITE) {\n        fmt.Printf(\"File closed: %s\\n\", event.Name)\n      }\n\n    case \u003c-time.After(5 * time.Second):\n      fmt.Println(\"Good bye!\")\n      cancel()\n      break main\n    }\n  }\n  \n  // Wait for watcher to finish all internal goroutines\n  \u003c-watcher.Done()\n  fmt.Println(\"Watcher is done\")\n  \n}\n```\n\n## License\nMIT. See [LICENSE](LICENSE) file for more details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fillarion%2Fgonotify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fillarion%2Fgonotify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fillarion%2Fgonotify/lists"}