Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dev-openapi/protoc-gen-go_api
根据proto文件生成go调用
https://github.com/dev-openapi/protoc-gen-go_api
client douyin douyin-api kuaishou-api open-api protobuf protobuf-go protoc-gen-go wechat wexin
Last synced: 23 days ago
JSON representation
根据proto文件生成go调用
- Host: GitHub
- URL: https://github.com/dev-openapi/protoc-gen-go_api
- Owner: dev-openapi
- License: apache-2.0
- Created: 2022-12-27T04:45:02.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-07-20T01:45:08.000Z (over 1 year ago)
- Last Synced: 2024-11-14T13:56:25.910Z (about 1 month ago)
- Topics: client, douyin, douyin-api, kuaishou-api, open-api, protobuf, protobuf-go, protoc-gen-go, wechat, wexin
- Language: Go
- Homepage:
- Size: 21.5 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# protoc-gen-go_api
一款用protobuf文件生成go的http调用代码。## 安装
```bash
go install github.com/dev-openapi/protoc-gen-go_api@latest
```## 使用
依赖googleapis的http.proto和annotations.proto。并且需要放到google/api/目录下
如果google/api是在工程文件目录下,执行以下脚本
```bash
protoc --go_api_out=out={dir}:. *.proto
```如果google/api在其他文件目录下,执行以下脚本
```bash
protoc --proto_path={yourpath}:. --go_api_out=:. *.proto
```## 注意
最新版本的protoc-gen-go要求go_package必须含有/,且会生成到$GOPATH/src目录下,所以建议把工程文件放到$GOPATH/src/git域名/git_group/目录下。
如 https://github.com/dev-openapi/wx-miniprogram 则该工程文件为 $GOPATH/src/github.com/dev-openapi/wx-miniprogram
另外,也可以指定protoc-gen-go的生成目录和设置source_relative相关配置,也可以生成到指定目录
如
```shell
protoc --go_out=.. --go_opt=paths=source_relative --go_api_out=out=..:. *.proto
```这样会生成到上一层目录