{"id":41318331,"url":"https://github.com/soyacen/goose","last_synced_at":"2026-05-15T19:32:23.503Z","repository":{"id":61627831,"uuid":"539858419","full_name":"soyacen/goose","owner":"soyacen","description":"Generate the Go v1.22 HTTP route file according to the rules of Google API","archived":false,"fork":false,"pushed_at":"2026-03-24T07:07:06.000Z","size":19228,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-25T08:16:11.887Z","etag":null,"topics":["gin","gin-gonic","go","golang","googleapis","protocol","restful","router"],"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/soyacen.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-09-22T07:41:10.000Z","updated_at":"2026-03-24T07:07:08.000Z","dependencies_parsed_at":"2024-01-12T05:41:22.817Z","dependency_job_id":"239d382a-abbf-4c76-83ef-78ef01994a77","html_url":"https://github.com/soyacen/goose","commit_stats":{"total_commits":135,"total_committers":3,"mean_commits":45.0,"dds":0.274074074074074,"last_synced_commit":"59e1b1603075e98f6b00ab4239ac68e6f88bc0f3"},"previous_names":["go-leo/gonic","go-leo/gors","soyacen/goose"],"tags_count":106,"template":false,"template_full_name":null,"purl":"pkg:github/soyacen/goose","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soyacen%2Fgoose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soyacen%2Fgoose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soyacen%2Fgoose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soyacen%2Fgoose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soyacen","download_url":"https://codeload.github.com/soyacen/goose/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soyacen%2Fgoose/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33076171,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T11:35:32.926Z","status":"ssl_error","status_checked_at":"2026-05-15T11:35:31.362Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["gin","gin-gonic","go","golang","googleapis","protocol","restful","router"],"created_at":"2026-01-23T05:43:44.498Z","updated_at":"2026-05-15T19:32:23.498Z","avatar_url":"https://github.com/soyacen.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Goose\n\nGoose 是一个面向 Go 的 Protobuf + HTTP/REST 代码生成与运行时支持库，包含用于生成客户端/服务器代码的 `protoc-gen-goose` 插件、服务端/客户端的编码解码器、以及一组常用中间件（访问日志、基本认证、JWT 验证、恢复、请求日志、超时等）。本仓库还包含示例 proto 文件、工具和测试用例，便于快速上手与二次开发。\n\n# 优点\n1. 基于proto文件，快速生成Restful服务路由和客户端\n2. 零配置\n3. 低依赖\n4. 非反射取值，效率非常高\n5. 稳定，所有方法经过单元测试\n6. 代码简单，良好的代码设计，减少出错\n7. 基于Go1.22标准库Http路由语法\n\n## 主要特性\n\n- protoc 插件：`cmd/protoc-gen-goose`，用于从 .proto 生成服务端/客户端样板代码。\n- 服务端/客户端编码器与解码器：位于 `server` 与 `client` 包，支持常见的请求/响应体映射。\n- 常用中间件：`middleware` 目录下包含访问日志、基本认证、JWT、恢复、请求日志、超时等实现，便于集成到生成的服务中。\n- 丰富的示例：`example` 目录包含多个基于 proto 的示例（body、path、query、response_body、user），包含生成后的 Go 文件与测试。\n- 辅助工具：验证、路径处理、pprof、格式化辅助等工具函数。\n\n## 目录概览\n\n- `cmd/protoc-gen-goose/`：protoc 插件源码（生成器、请求/响应模版等）。\n- `client/`：客户端相关的编码/解码与中间件选项。\n- `server/`：服务端相关的编码/解码与中间件选项。\n- `middleware/`：一组可复用的中间件实现（accesslog、basicauth、jwtauth、recovery、requestlog、timeout 等）。\n- `example/`：示例 proto 与生成的 Go 文件，演示如何使用插件和运行生成代码。\n- `internal/`、`tools/`：库内部工具与构建脚本。\n\n## 快速开始\n\n下面展示一个最小的使用流程：安装插件、用 protoc 生成代码、运行示例。\n\n### 安装（编译插件）\n\n推荐使用 go install 来安装插件（在支持 Go Modules 的环境下）：\n\n```bash\ngo install github.com/soyacen/goose/cmd/protoc-gen-goose@latest\n```\n\n这会在 `$GOBIN` 或 `$GOPATH/bin` 下生成 `protoc-gen-goose` 可执行文件，protoc 能自动找到并使用它。\n\n\u003e 也可以在仓库根目录下直接 `go build ./cmd/protoc-gen-goose`，得到本地可执行文件用于开发或调试。\n\n### 生成代码\n\n仓库内 `example/protoc.sh` 提供了示例生成命令。下面给出一个典型的 protoc 调用示例：\n\n```bash\n# 假设当前在 example 目录，且 protoc-gen-goose 在 PATH\nprotoc --go_out=. --go-grpc_out=. --goose_out=. \\\n  --proto_path=. your_service.proto\n```\n\n生成后的文件通常包含：\n- Protobuf 消息类型的 Go 实现（由 `protoc-gen-go` 生成）\n- 基于 Goose 的服务端与客户端样板（由 `protoc-gen-goose` 生成）\n\n具体的插件选项和生成路径请参考 `cmd/protoc-gen-goose` 的源码与 `example/protoc.sh` 脚本。\n\n## 快速示例（运行生成的服务）\n\n仓库的 `example` 目录包含多个示例服务。一般步骤：\n\n1. 进入对应示例目录（例如 `example/body`）。\n2. 运行 `example/protoc.sh`（或手动执行 `protoc`）生成 Go 代码。\n3. 在生成后的代码中，使用生成的服务端构建器并挂载中间件（如需要），然后启动 HTTP 服务器。\n4. 使用生成的客户端（或 curl/postman）调用接口并查看响应。\n\n示例中也包含对应的测试文件（`*_test.go`），可直接运行 `go test` 来查看行为。\n\n## 中间件\n\n`middleware` 目录下包含若干实现：\n\n- `accesslog`：记录访问日志\n- `basicauth`：HTTP 基本认证\n- `jwtauth`：JWT 验证（示例与实现位于子模块中）\n- `recovery`：捕获 panic 并返回 5xx\n- `requestlog`：请求级别详细日志\n- `timeout`：请求超时控制\n\n这些中间件可以与生成的服务端代码组合使用，或在自定义的 HTTP/框架中复用。\n\n## 本地开发与测试\n\n- 运行所有包的测试：\n\n```bash\ngo test ./...\n```\n\n- 在更改 `cmd/protoc-gen-goose` 后，重新编译并在 `example` 下运行 `protoc` 生成最新代码进行联调。\n\n## 贡献\n\n欢迎贡献：提交 issue、PR 或在 `cmd/protoc-gen-goose` 中添加更多生成选项与模板。贡献指南：\n\n1. Fork 仓库并在 feature 分支开发。\n2. 增加/更新测试以覆盖你的改动。\n3. 提交 PR，并在描述中说明变更目的与影响范围。\n\n## 相关链接与参考\n\n- `example/`：查看如何使用插件生成代码并运行示例。\n- `cmd/protoc-gen-goose`：插件实现，查看如何扩展生成模板。\n\n## 许可证\n\n本项目遵循仓库中的 LICENSE 文件（请参阅 `LICENSE`）。\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoyacen%2Fgoose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoyacen%2Fgoose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoyacen%2Fgoose/lists"}