{"id":24969299,"url":"https://github.com/yianandcode/fwalert-go","last_synced_at":"2025-06-21T20:03:10.050Z","repository":{"id":64301826,"uuid":"403678251","full_name":"YianAndCode/fwalert-go","owner":"YianAndCode","description":"The SDK of Fw:Alert in golang | 「饭碗警告」Go SDK","archived":false,"fork":false,"pushed_at":"2021-09-10T16:30:47.000Z","size":5,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-21T20:02:35.469Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/YianAndCode.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}},"created_at":"2021-09-06T15:46:48.000Z","updated_at":"2025-04-11T11:21:55.000Z","dependencies_parsed_at":"2023-01-15T09:30:37.992Z","dependency_job_id":null,"html_url":"https://github.com/YianAndCode/fwalert-go","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/YianAndCode/fwalert-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YianAndCode%2Ffwalert-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YianAndCode%2Ffwalert-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YianAndCode%2Ffwalert-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YianAndCode%2Ffwalert-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YianAndCode","download_url":"https://codeload.github.com/YianAndCode/fwalert-go/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YianAndCode%2Ffwalert-go/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261186369,"owners_count":23121937,"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":[],"created_at":"2025-02-03T14:37:09.185Z","updated_at":"2025-06-21T20:03:05.028Z","avatar_url":"https://github.com/YianAndCode.png","language":"Go","readme":"# Fw: Alert 是什么\n\n[饭碗警告（Fw: Alert）](https://fwalert.com/115)可以轻松将 webhook（HTTP 请求）、邮件转发为短信、电话等报警，内置强大的模板变量提取功能，既可以轻松与任意监控系统组合使用，也可以快速接入自研监控系统。\n\n## Fw: Alert Go SDK\n\n本 SDK 对 Fw: Alert 的 webhook 模式进行了封装，让你可以无需关注 HTTP 请求，只需几行代码即可快速在你的 Go 项目中接入 `饭碗警告`。  \n*\\*如需在 PHP 项目中使用，请移步：[https://github.com/YianAndCode/fwalert-php-sdk](https://github.com/YianAndCode/fwalert-php-sdk)*\n\n在开始之前，请确保你已经注册好了[饭碗警告](https://fwalert.com/115)（点击左侧链接直达注册页）。\n\n## 使用方式\n\n首先在你的项目目录中执行：\n\n```bash\ngo get -u github.com/YianAndCode/fwalert-go\n```\n\n然后在代码中引入包：\n\n```golang\nimport \"github.com/YianAndCode/fwalert-go\"\n```\n\n接下来只需要：\n\n```golang\nfw := fwalert.New()\nfw.SendAlert(\n    context.Background(), // 如果你是在诸如 gin 之类的框架中使用，则传入 gin.Context 也可\n    \"这里替换成在饭碗警告后台拿到的 webhook url\",\n    map[string]string{\n\t\t\"hello\": \"world\", // 这里可以传任意你想要在告警文案中展示的字段，key-value 格式即可\n\t},\n)\n```\n\n## 进阶用法\n\n本 SDK 除了封装 HTTP 请求外，还增加了“频道”的概念：当你设置了多个告警规则的时候，不需要在你的代码中 New 一堆 fwalert 出来，只需要：\n\n```golang\nfw := fwalert.New()\n\n// 提前注册好“频道”\nfw.AddChannel(\"ch1\", \"webhook_url1\")\nfw.AddChannel(\"ch2\", \"webhook_url2\")\n// ...\n\nfw.Send(\n    context.Background(),\n    \"ch1\", // 后续只需要使用频道别名就可以发送到指定的告警规则了\n    map[string]string{\n        \"hello\": \"world\"\n    }\n)\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyianandcode%2Ffwalert-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyianandcode%2Ffwalert-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyianandcode%2Ffwalert-go/lists"}