Skip to content

dev-openapi/protoc-gen-go_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

protoc-gen-go_api

一款用protobuf文件生成go的http调用代码。

安装

go install github.com/dev-openapi/protoc-gen-go_api@latest

使用

依赖googleapis的http.proto和annotations.proto。并且需要放到google/api/目录下

如果google/api是在工程文件目录下,执行以下脚本

protoc --go_api_out=out={dir}:. *.proto

如果google/api在其他文件目录下,执行以下脚本

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相关配置,也可以生成到指定目录

protoc --go_out=.. --go_opt=paths=source_relative --go_api_out=out=..:. *.proto

这样会生成到上一层目录

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy