Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/go-leo/gors-protoc
gors 的 protobuffer 插件
https://github.com/go-leo/gors-protoc
Last synced: about 1 month ago
JSON representation
gors 的 protobuffer 插件
- Host: GitHub
- URL: https://github.com/go-leo/gors-protoc
- Owner: go-leo
- Created: 2023-05-15T03:59:44.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-19T01:12:36.000Z (11 months ago)
- Last Synced: 2024-06-21T00:05:50.996Z (6 months ago)
- Language: Go
- Size: 104 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 简介
基于 `protobuf` 的API工程化demo.其中包含两个自定义插件用于 http 网关代码生成:
- protoc-gen-go-gorsp 生成 gin 代码
- protoc-go-inject-tagp 修改 pb 结构体中的标签# quick start
1. 安装
```shell
# 生成 pb.go
go install google.golang.org/protobuf/cmd/[email protected]
# 生成 grpc.pb.go
go install google.golang.org/grpc/cmd/[email protected]
# 生成 gin http
go install ./cmd/protoc-gen-go-gorsp
# 补充 字段 tag
go install ./cmd/protoc-go-inject-tagp
# 生成 validate 代码
go install github.com/envoyproxy/[email protected]
# 生成 swagger
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger```
1. 运行exmaple
```shell
cd ./example/gors/api
make api
```
最终会生成如下文件:```go
// api文档
example/gors/api/api.swagger.json
// pb文件
example/gors/api/api.pb.go
// grpc文件
example/gors/api/api_grpc.pb.go
// http文件
example/gors/api/api_http.pb.go
// 参数校验文件
example/gors/api/api.pb.validate.go
```