{"id":17933592,"url":"https://github.com/matrix86/cloudwatcher","last_synced_at":"2026-03-07T12:37:16.321Z","repository":{"id":57565822,"uuid":"336562032","full_name":"Matrix86/cloudwatcher","owner":"Matrix86","description":"File system notification for Cloud platforms (and not) in Golang.","archived":false,"fork":false,"pushed_at":"2023-12-19T14:41:38.000Z","size":175,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-04T21:51:07.307Z","etag":null,"topics":["cloud-platforms","dropbox","dropbox-api","filesystem","fsnotify","gdrive","go","golang","google","google-drive","library","notification","notification-service","polling","s3","watchers"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Matrix86.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}},"created_at":"2021-02-06T14:55:12.000Z","updated_at":"2023-11-07T12:56:43.000Z","dependencies_parsed_at":"2023-12-19T17:32:59.719Z","dependency_job_id":"dfd60db8-c83b-4faf-8ea3-380d781862fa","html_url":"https://github.com/Matrix86/cloudwatcher","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/Matrix86/cloudwatcher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matrix86%2Fcloudwatcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matrix86%2Fcloudwatcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matrix86%2Fcloudwatcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matrix86%2Fcloudwatcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Matrix86","download_url":"https://codeload.github.com/Matrix86/cloudwatcher/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matrix86%2Fcloudwatcher/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276367053,"owners_count":25629964,"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","status":"online","status_checked_at":"2025-09-22T02:00:08.972Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cloud-platforms","dropbox","dropbox-api","filesystem","fsnotify","gdrive","go","golang","google","google-drive","library","notification","notification-service","polling","s3","watchers"],"created_at":"2024-10-28T21:40:51.653Z","updated_at":"2025-09-22T07:31:58.180Z","avatar_url":"https://github.com/Matrix86.png","language":"Go","readme":"# Cloudwatcher\n![GitHub](https://img.shields.io/github/license/Matrix86/cloudwatcher)\n![GitHub release (latest by date)](https://img.shields.io/github/v/release/Matrix86/cloudwatcher)\n![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/Matrix86/cloudwatcher)\n![Build and Test](https://github.com/Matrix86/cloudwatcher/workflows/Build%20and%20Test/badge.svg) \n![Codecov](https://img.shields.io/codecov/c/github/Matrix86/cloudwatcher)\n\nFile system notification for Cloud platforms (and not) in Golang.\n\ncloudwatcher is a file system notification library for cloud platforms (and not) in Go. \nCurrently it implements the watchers for the following services:\n- Amazon S3\n- Google Drive\n- Dropbox\n- Git\n- local filesystem (fsnotify/polling)\n\nIt is possible specify the directory to monitor and the polling time (how much often the watcher should check that directory), \nand every time a new file is added, removed or changed, an event is generated and sent to the `Events` channel.\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/Matrix86/cloudwatcher\"\n)\n\nfunc main() {\n    // the first parameter is the type of service to use: local, dropbox, gdrive or s3\n\ts, err := cloudwatcher.New(\"local\", \"/home/user/tests\", time.Second)\n\tif err != nil {\n\t\tfmt.Printf(\"ERROR: %s\", err)\n\t\treturn\n\t}\n\n\tconfig := map[string]string{\n\t\t\"disable_fsnotify\": \"false\",\n\t}\n\n\terr = s.SetConfig(config)\n\tif err != nil {\n\t\tfmt.Printf(\"ERROR: %s\", err)\n\t\treturn\n\t}\n\n\terr = s.Start()\n\tdefer s.Close()\n\tfor {\n\t\tselect {\n\t\tcase v := \u003c-s.GetEvents():\n\t\t\tfmt.Printf(\"EVENT: %s %s\\n\", v.Key, v.TypeString())\n\n\t\tcase e := \u003c-s.GetErrors():\n\t\t\tfmt.Printf(\"ERROR: %s\\n\", e)\n\t\t}\n\t}\n}\n```\n\nThe channel returned by `GetEvents()` function, will return an [Event](event.go) struct that contains the event type, the Key\nwith the name of the file that generates the event and the object itself.\n\n\u003e :warning: check the Event.Object field before use it...in some cases it could be nil (FileDelete event with fsnotify)  \n\n## Amazon S3\n\nThe config of the S3 watcher is the following:\n\n```go\nconfig := map[string]string{\n    \"bucket_name\": \"storage\",\n    \"endpoint\":   \"s3-us-west-2.amazonaws.com\",\n    \"access_key\":  \"user\",\n    \"secret_key\":  \"secret\",\n    \"token\":      \"\",\n    \"region\":     \"us-west-2\",\n    \"ssl_enabled\": \"true\",\n}\n```\n\nTo use [AWS IAM credentials or AWS file](https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html#specifying-credentials), it is possible to set one of the following vars to \"`true`\": `aws_iam_credentials`, `aws_file`.\nIt is also possible to specify the IAM endpoint (`aws_file_profile`) or the path of the file to use (`aws_file_profile`), if not specified it will use the default endpoint and file ($HOME/.aws/credentials).\n\n```go\nconfig := map[string]string{\n    \"aws_file_profile\": \"true\",\n}\n```\n\nAn example can be found [here](examples/s3/s3.go).\n\n\u003e :gem: [minio](https://docs.min.io/docs/minio-quickstart-guide.html) can be used for testing purposes\n\n## Google Drive\n\nIn order to use it you need to enable the drive API from [here](https://developers.google.com/drive/api/v3/enable-drive-api) .\nAfter that you can specify the `client-id` and the `client-secret` on the config file. \nThe logic to retrieve the token has to be handled outside the library and the `token` field should contain the json. \n\nYou can find an example in the [examples directory](examples/gdrive/gdrive.go). \n\n```go\nconfig := map[string]string{\n    \"debug\":         \"true\",\n    \"token\":         Token,\n    \"client_id\":     ClientId,\n    \"client_secret\": ClientSecret,\n}\n```\n\n## Dropbox\n\nFirst, you need to register a new app from the [developer console](https://www.dropbox.com/developers/).\nUse the `client-id` and the `client-secret` to retrieve the user token and use it on the `token` field of the config.\n\nYou can find an example in the [examples directory](examples/dropbox/dropbox.go). \n\n```go\nconfig := map[string]string{\n    \"debug\": \"true\",\n    \"token\": Token,\n}\n```\n\n## Local filesystem\n\nIt is based on [fsnotify](https://github.com/fsnotify/fsnotify) library, so it is cross platform: Windows, Linux, BSD and macOS.\nIt is not mandatory to call the `SetConfig()` function, and the polling time argument of `cloudwatcher.New` is not used.\n\nSetting `disable_fsnotify` parameter on config to \"true\" the watcher doesn't use fsnotify and use the listing approach instead.\n\n\u003e :warning: not set `disable_fsnotify` to \"true\" if you plan to use it on a big directory!!! It could increase the I/O on disk\n\n## Git\n\nGit watcher has the following configurations:\n\n| Name | Description \n| --- | --- |\n| `debug` | if \"true\" the debug mode is enabled (default \"false\") |\n| `monitor_type` | it can be \"file\" or \"repo\" (default is \"repo\") |\n| `auth_type` | authentication type to use: \"none\", \"ssh\", \"http_token\", \"http_user_pass\" (default \"none\") |\n| `ssh_pkey` | path of the ssh private key (required if auth_type = \"ssh\") |\n| `ssh_pkey_password` | password of the private key if set |\n| `http_token` | token to use if auth_type = \"http_token\" |\n| `http_username` | username of github account (auth_type = \"http_user_pass\") |\n| `http_password` | password of github account (auth_type = \"http_user_pass\") |\n| `repo_url` | url of the repository |\n| `repo_branch` | branch to watch (if `monitor_type` is \"repo\" you can leave it empty to watch all the branches) |\n| `assemble_events` | if \"true\" the events could contain one or more commit events (only if `monitor_type` = \"repo\") |\n| `temp_dir` | temporary directory to use for clone the repo: if empty the tmp dir will be used |\n\nIf `monitor_type` is set to \"repo\", the event channel will receive an event with the `Object` field filled with commits or tags.\nIf `assemble_events` is \"true\" the `Object` field could contains one or more commits.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatrix86%2Fcloudwatcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatrix86%2Fcloudwatcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatrix86%2Fcloudwatcher/lists"}