Create & Init Project...

This commit is contained in:
2019-04-22 18:49:16 +08:00
commit fc4fa37393
25440 changed files with 4054998 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
### bmproto
### v1.0.7
- 路径加入双引号,兼容路径含空格的情况
### v1.0.6
- md文档 json改成javascript
### v1.0.0
- generate code for blademaster
### v1.0.1
- 支持 option (google.api.http)
### v1.0.2
- 支持 project 里的internal
### v1.0.2
- autodoc 支持 jsontag
### v1.0.3
- 使用proto.sh脚本生成grpc代码和主站保持一直
### v1.0.5
- 请求参数可以是Json

View File

@@ -0,0 +1,8 @@
# Owner
liugang
# Author
all
# Reviewer
all

8
app/tool/bmproto/OWNERS Normal file
View File

@@ -0,0 +1,8 @@
# See the OWNERS docs at https://go.k8s.io/owners
approvers:
- liugang
labels:
- tool
options:
no_parent_owners: true

275
app/tool/bmproto/README.md Normal file
View File

@@ -0,0 +1,275 @@
# 目录
<!-- vim-markdown-toc GitLab -->
* [简介](#简介)
* [HTTP访问](#http访问)
* [grpc](#grpc)
* [安装](#安装)
* [用法](#用法)
* [生成结果](#生成结果)
* [命名规范](#命名规范)
* [proto包名与版本号](#proto包名与版本号)
* [生成的go文件的包名](#生成的go文件的包名)
* [多个proto文件](#多个proto文件)
* [其他特性](#其他特性)
* [添加http框架的Middleware](#添加http框架的middleware)
* [自定义Url或者指定http方法为post](#自定义url或者指定http方法为post)
* [生成service模板](#生成service模板)
* [form tag和json tag](#form-tag和json-tag)
* [指定输入参数的约束条件](#指定输入参数的约束条件)
* [同步Markdown文档到live-doc仓库直播Only](#同步markdown文档到live-doc仓库直播only)
* [支持json做为输入](#支持json做为输入)
* [直播部门老的用法](#直播部门老的用法)
* [兼容直播服务列表按照discovery id](#兼容直播服务列表按照discovery-id)
<!-- vim-markdown-toc -->
## 简介
根据protobuf文件生成grpc和blademaster框架http代码及文档
```protobuf
syntax = "proto3";
package department.app;
option go_package = "api";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
service Greeter{
// api 标题
// api 说明
rpc SayHello(HelloRequest) returns (HelloResponse);
}
message HelloRequest {
// 请求参数说明
string param1 = 1 [(gogoproto.moretags) = 'form:"param1"'];
}
message HelloResponse {
// 返回字段说明
string ret_string = 1 [(gogoproto.jsontag) = 'ret_string'];
}
```
#### HTTP访问
```
GET /department.app.Greeter/SayHello?param1=p1
响应
{
"code": 0,
"message": "ok",
"data": {
"ret_string": "anything"
}
}
```
#### grpc
路径 /department.app.Greeter/SayHello
## 安装
```shell
go install go-common/app/tool/bmproto/...
```
## 用法
- cd 项目目录
- 在 api目录下新建api.proto文件(参见上面的例子) 例如 api/api.proto
- 运行 bmgen在项目的任意位置
- 创建 internal/service/greeter.go(这是写业务代码的地方)也可以通过bmgen -t直接生成
```go
import pb "path-to-project/api"
....
// 实现 pb.GreeterBMServer 和 grpc的 pb.GreeterServer
type GreeterService struct {
}
func (s *GreeterService) SayHello(ctx context.Context, req *pb.SayHelloRequest)
(resp *pb.SayHelloResp, err error) {
}
```
- 在server/http.go 初始化代码(一般是`route`方法)里加入代码
```go
import pb "path-to-project/api"
import svc "path-to-project/internal/service"
......
pb.RegisterGreeterBMServer(engine, &svc.GreeterService{})
```
- 如果是grpc 在server/grpc/server.go 初始化里面加入代码
`pb.RegisterGreeterServer(grpcServer, &svc.GreeterService{})`
- 启动服务
- 访问接口 `curl 127.0.0.1:8000/department.app.Greeter/SayHello` (默认路由规则为 `/package.service/method`)
### 生成结果
```
project-
|------|--internal/service/greeter.go (使用bmgen -t 会生成如果proto新增加方法会自动往这里面添加模板代码
|--api/
|--api.greeter.md (HTTP API文档)
|--api.bm.go
|--api.pb.go
|--api.proto
```
## 命名规范
### proto包名与版本号
- DISCOVERY_ID 或者 DISCOVERY_ID.v*
- DISCOVERY_ID的构成为 `部门.服务` 并且去掉中划线
- 第一个版本不用加版本号从第二个版本加v2
- **示例** 部门 department 服务 hello-world 则 package为`department.helloworld`, 文件目录为api/
- 第二个版本package `department.helloworld.v2", 目录为api/v2
### 生成的go文件的包名
- golang一般原则上保持包名和目录名一致
- proto 可以指定`option go_package = "xxx"; `
比如对于api/api.proto `option go_package = "api"; `
对于api/v2/api.proto `option go_package = "v2"; `
### 多个proto文件
一个文件夹下面可以有多个proto文件但是要满足以下约束
- 同目录下的proto package 一致
- message service 等定义不能重复因为是在统一package下面
## 其他特性
### 添加http框架的Middleware
在RegisterXXBMServer之前加入代码
```
bm.Inject(pb.PathGreeterSayHello, middleware1, middleware2)
```
### 自定义Url或者指定http方法为post
```protobuf
.....
package department.app;
....
import "google/api/annotations.proto";
....
service Greeter{
rpc SayHelloCustomUrl(HelloRequest) returns (HelloResponse) {
option (google.api.http) = {
get:"/say_hello" // GET /say_hello
};
};
rpc SayHelloPost(HelloRequest) returns (HelloResponse) {
option (google.api.http) = {
post:"" // POST /department.app.Greeter/SayHelloPost
};
};
}
```
### 生成service模板
`bmgen -t` 生成service模板代码在 internal/service/serviceName.go
### form tag和json tag
```
对于HTTP接口
现在请求字段需要加上form tag以解析请求参数
响应参数需要加上json tag 以避免 字段为0或者空字符串时不显示
这两个tag都建议和字段名保持一致
现在是必须加将来考虑维护一个自己的proto仓库以移除这个多余的tag
```
### 指定输入参数的约束条件
```protobuf
...
import "github.com/gogo/protobuf/gogoproto/gogo.proto"
...
message Request {
int param1 = 1 [(gogoproto.moretags) = 'validate:"required"')]; // 参数必传不能等于0
}
```
### 同步Markdown文档到live-doc仓库直播Only
`bmgen -l`
### 支持json做为输入
```
curl 127.0.0.1:8000/department.app.Greeter/SayHello -H "Content-Type: application/json" -d "{"param1":"p1"}" -X POST
```
## 直播部门老的用法
**对于以下"兼容直播服务列表中的服务"有效**
- URL/xlive/项目名/v*/service开头小写/method
- 注册路由使用RegisterXXXService而不是 RegisterXXBMServer
- middleware不支持RegisterXXXMiddleware 而是 使用注解
```go
api/api.proto
service Greeter {
// `method:"POST"` // 表示请求方法为POST
// `midware:"user"`
rpc SayHello(A) returns (B);
}
// server/http/http.go
import bm "go-common/library/net/http/blademaster"
....
userAuthMiddleware := xxxxx
pb.RegisterXXService(e, svc, map[string]bm.HandlerFunc{"user":userAuthMiddleware})
```
- 注解,在方法或者字段上方的注视添加和 go的tag格式一样的注解实现一定的功能
注解列表:
| key | 位置 | 说明 |
| ------------ | --------------------- | ------------------------------------------------------------ |
| midware | rpc method上方 | midware:"auth,verify" 中间件auth 是验证登录态verify是校验签名 |
| method | rpc method上方 | method:"POST" 指定http请求方法 |
| mock | 响应message的字段上方 | mock:"mockdata" mock数据生成文档的时候有用 |
| internal | 不建议继续使用 | 不建议继续使用 |
| dynamic | 不建议继续使用 | 不建议继续使用 |
| dynamic_resp | 不建议继续使用 | 不建议继续使用 |
### 兼容直播服务列表按照discovery id
- "live.webucenter"
- "live.webroom"
- "live.appucenter"
- "live.appblink"
- "live.approom"
- "live.appinterface"
- "live.liveadmin"
- "live.resource"
- "live.livedemo"
- "live.lotteryinterface"

View File

@@ -0,0 +1,39 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
"go_library",
)
go_binary(
name = "bmgen",
embed = [":go_default_library"],
tags = ["automanaged"],
)
go_library(
name = "go_default_library",
srcs = ["main.go"],
importpath = "go-common/app/tool/bmproto/bmgen",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//vendor/github.com/pkg/errors:go_default_library",
"//vendor/github.com/urfave/cli:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,420 @@
package main
import (
"bufio"
"fmt"
"io/ioutil"
"log"
"net/url"
"os"
"os/exec"
"os/user"
"path"
"path/filepath"
"regexp"
"strconv"
"strings"
"time"
"github.com/pkg/errors"
"github.com/urfave/cli"
)
var tplFlag = false
var grpcFlag = false
// 使用app/tool/warden/protoc.sh 生成grpc .pb.go
var protocShRunned = false
var syncLiveDoc = false
func main() {
app := cli.NewApp()
app.Name = "bmgen"
app.Usage = "根据proto文件生成bm框架或者grpc代码: \n" +
"用法1在项目的任何一个位置运行bmgen会自动找到proto文件\n" +
"用法2bmgen proto文件(文件必须在一个项目的api中项目包含cmd和api目录)\n"
app.Version = "1.0.0"
app.Commands = []cli.Command{
{
Name: "update",
Usage: "更新工具本身",
Action: actionUpdate,
},
{
Name: "clean-live-doc",
Usage: "清除live-doc已经失效的分支的文档",
Action: actionCleanLiveDoc,
},
}
app.Action = actionGenerate
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "interface, i",
Value: "",
Usage: "generate for the interface project `RELATIVE-PATH`, eg. live/live-demo",
},
cli.BoolFlag{
Name: "grpc, g",
Destination: &grpcFlag,
Usage: "废弃会自动检测是否需要grpc",
},
cli.BoolFlag{
Name: "tpl, t",
Destination: &tplFlag,
Usage: "是否生成service模板代码",
},
cli.BoolFlag{
Name: "live-doc, l",
Destination: &syncLiveDoc,
Usage: "同步该项目的文档到live-doc https://git.bilibili.co/live-dev/live-doc/tree/doc/proto/$branch/$package/$filename.$Service.md",
},
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}
func autoUpdate(ctx *cli.Context) (err error) {
tfile, e := ioutil.ReadFile("/tmp/bmgentime")
if e != nil {
tfile = []byte{'0'}
}
ts, _ := strconv.ParseInt(string(tfile), 0, 64)
current := time.Now().Unix()
if (current - int64(ts)) > 3600*12 { // 12 hours old
ioutil.WriteFile("/tmp/bmgentime", []byte(strconv.FormatInt(current, 10)), 0777)
err = actionUpdate(ctx)
if err != nil {
return
}
}
return
}
func actionCleanLiveDoc(ctx *cli.Context) (err error) {
fmt.Println("暂未实现,敬请期待")
return
}
func installDependencies() (err error) {
// 检查protoc
//
e := runCmd("which protoc")
if e != nil {
var uname string
uname, err = runCmdRet("uname")
if err != nil {
return
}
if uname == "Darwin" {
err = runCmd("brew install protobuf")
if err != nil {
return
}
} else {
fmt.Println("找不到protoc请于 https://github.com/protocolbuffers/protobuf/releases 下载里面的protoc-$VERSION-$OS.zip 安装, 注意把文件拷贝到正确的未知")
return errors.New("找不到protoc")
}
}
err = runCmd("which protoc-gen-gogofast || go get github.com/gogo/protobuf/protoc-gen-gogofast")
return
}
// actionGenerate invokes protoc to generate files
func actionGenerate(ctx *cli.Context) (err error) {
if err = autoUpdate(ctx); err != nil {
return
}
err = installDependencies()
if err != nil {
return
}
f := ctx.Args().Get(0)
goPath := initGopath()
if !fileExist(goPath) {
return cli.NewExitError(fmt.Sprintf("GOPATH not exist: "+goPath), 1)
}
filesToGenerate := []string{f}
iPath := ctx.String("i")
if iPath != "" {
iPath = goPath + "/src/go-common/app/interface/" + iPath
if !fileExist(iPath) {
return cli.NewExitError(fmt.Sprintf("interface project not found: "+iPath), 1)
}
pbs := filesWithSuffix(iPath+"/api", ".pb", ".proto")
if len(pbs) == 0 {
return cli.NewExitError(fmt.Sprintf("no pbs found in path: "+iPath+"/api"), 1)
}
filesToGenerate = pbs
fmt.Printf(".pb files found %v\n", pbs)
} else {
if f == "" {
// if is is empty, look up project that contains current dir
abs, _ := filepath.Abs(".")
proj := lookupProjPath(abs)
if proj == "" {
return cli.NewExitError("current dir is not in any project : "+abs, 1)
}
if proj != "" {
pbs := filesWithSuffix(proj+"/api", ".pb", ".proto")
if len(pbs) == 0 {
return cli.NewExitError(fmt.Sprintf("no pbs found in path: "+proj+"/api"), 1)
}
filesToGenerate = pbs
fmt.Printf(".pb files found %v\n", pbs)
}
}
}
for _, p := range filesToGenerate {
if !fileExist(p) {
return cli.NewExitError(fmt.Sprintf("file not exist: "+p), 1)
}
generateForFile(p, goPath)
}
if syncLiveDoc {
err = actionSyncLiveDoc(ctx)
}
return
}
func generateForFile(f string, goPath string) {
absPath, _ := filepath.Abs(f)
base := filepath.Base(f)
projPath := lookupProjPath(absPath)
fileFolder := filepath.Dir(absPath)
var relativePath string
if projPath != "" {
relativePath = absPath[len(projPath)+1:]
}
var cmd string
if strings.Index(relativePath, "api/liverpc") == 0 {
// need not generate for liverpc
fmt.Printf("skip for liverpc \n")
return
}
genTpl := 0
if tplFlag {
genTpl = 1
}
if !strings.Contains(relativePath, "api/http") {
//非http 生成grpc和http的代码
isInsideGoCommon := strings.Contains(fileFolder, "go-common")
if !protocShRunned && isInsideGoCommon {
//protoc.sh 只能在大仓库中使用
protocShRunned = true
cmd = fmt.Sprintf(`cd "%s" && "%s/src/go-common/app/tool/warden/protoc.sh"`, fileFolder, goPath)
runCmd(cmd)
}
genGrpcArg := "--gogofast_out=plugins=grpc:."
if isInsideGoCommon {
// go-common中已经用上述命令生成过了
genGrpcArg = ""
}
cmd = fmt.Sprintf(`cd "%s" && protoc --bm_out=tpl=%d:. `+
`%s -I. -I%s/src -I"%s/src/go-common" -I"%s/src/go-common/vendor" "%s"`,
fileFolder, genTpl, genGrpcArg, goPath, goPath, goPath, base)
} else {
// 只生成http的代码
var pbOutArg string
if strings.LastIndex(f, ".pb") == len(f)-3 {
// ends with .pb
log.Printf("\n\033[0;33m======WARNING========\n" +
".pb文件生成代码的功能已经不再维护请尽快迁移到.proto, 详情:\nhttp://info.bilibili.co/pages/viewpage.action?pageId=11864735#proto文件格式-.pb迁移到.proto\n" +
"======WARNING========\033[0m\n")
pbOutArg = "--gogofasterg_out=json_emitdefault=1,suffix=.pbg.go:."
} else {
pbOutArg = "--gogofast_out=."
}
cmd = fmt.Sprintf(`cd "%s" && protoc --bm_out=tpl=%d:. `+
pbOutArg+` -I. -I"%s/src" -I"%s/src/go-common" -I"%s/src/go-common/vendor" "%s"`,
fileFolder, genTpl, goPath, goPath, goPath, base)
}
err := runCmd(cmd)
if err == nil {
fmt.Println("ok")
}
}
// files all files with suffix
func filesWithSuffix(dir string, suffixes ...string) (result []string) {
filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
if !info.IsDir() {
for _, suffix := range suffixes {
if strings.HasSuffix(info.Name(), suffix) {
result = append(result, path)
break
}
}
}
return nil
})
return
}
// 扫描md文档并且同步到live-doc
func actionSyncLiveDoc(ctx *cli.Context) (err error) {
//mdFiles := filesWithSuffix(
// if is is empty, look up project that contains current dir
abs, _ := filepath.Abs(".")
proj := lookupProjPath(abs)
if proj == "" {
err = cli.NewExitError("current dir is not in any project : "+abs, 1)
return
}
var branch string
branch, err = runCmdRet("git rev-parse --abbrev-ref HEAD")
if err != nil {
return
}
branch = url.QueryEscape(branch)
err = runCmd("[ -d ~/.brpc ] || mkdir ~/.brpc")
if err != nil {
return
}
var liveDocUrl = "git@git.bilibili.co:live-dev/live-doc.git"
err = runCmd("cd ~/.brpc && [ -d ~/.brpc/live-doc ] || git clone " + liveDocUrl)
if err != nil {
return
}
err = runCmd("cd ~/.brpc/live-doc && git checkout doc && git pull origin doc")
if err != nil {
return
}
mdFiles := filesWithSuffix(proj+"/api", ".md")
var u *user.User
u, err = user.Current()
if err != nil {
return err
}
var liveDocDir = u.HomeDir + "/.brpc/live-doc"
for _, file := range mdFiles {
fileHandle, _ := os.Open(file)
fileScanner := bufio.NewScanner(fileHandle)
for fileScanner.Scan() {
var text = fileScanner.Text()
var reg = regexp.MustCompile(`package=([\w\.]+)`)
matches := reg.FindStringSubmatch(text)
if len(matches) >= 2 {
pkg := matches[1]
relativeDir := strings.Replace(pkg, ".", "/", -1)
var destDir = liveDocDir + "/protodoc/" + branch + "/" + relativeDir
runCmd("mkdir -p " + destDir)
err = runCmd(fmt.Sprintf("cp %s %s", file, destDir))
if err != nil {
return
}
} else {
fmt.Println("package not found", file)
}
break
}
fileHandle.Close()
}
err = runCmd(`cd "` + liveDocDir + `" && git add -A`)
if err != nil {
return
}
var gitStatus string
gitStatus, _ = runCmdRet(`cd "` + liveDocDir + `" && git status --porcelain`)
if gitStatus != "" {
err = runCmd(`cd "` + liveDocDir + `" && git commit -m 'update doc from proto' && git push origin doc`)
if err != nil {
return
}
}
fmt.Printf("文档已经生成至 %s%s\n", "https://git.bilibili.co/live-dev/live-doc/tree/doc/protodoc/", url.QueryEscape(branch))
return
}
// actionUpdate update the tools its self
func actionUpdate(ctx *cli.Context) (err error) {
log.Print("Updating bmgen.....")
goPath := initGopath()
goCommonPath := goPath + "/src/go-common"
if !fileExist(goCommonPath) {
return cli.NewExitError("go-common not exist : "+goCommonPath, 1)
}
cmd := fmt.Sprintf(`go install "go-common/app/tool/bmproto/..."`)
if err = runCmd(cmd); err != nil {
err = cli.NewExitError(err.Error(), 1)
return
}
log.Print("Updated!")
return
}
// runCmd runs the cmd & print output (both stdout & stderr)
func runCmd(cmd string) (err error) {
fmt.Printf("CMD: %s \n", cmd)
out, err := exec.Command("/bin/bash", "-c", cmd).CombinedOutput()
fmt.Print(string(out))
return
}
func runCmdRet(cmd string) (out string, err error) {
fmt.Printf("CMD: %s \n", cmd)
outBytes, err := exec.Command("/bin/bash", "-c", cmd).CombinedOutput()
out = strings.Trim(string(outBytes), "\n\r\t ")
return
}
// lookupProjPath get project path by proto absolute path
// assume that proto is in the project's model directory
func lookupProjPath(protoAbs string) (result string) {
lastIndex := len(protoAbs)
curPath := protoAbs
for lastIndex > 0 {
if fileExist(curPath+"/cmd") && fileExist(curPath+"/api") {
result = curPath
return
}
lastIndex = strings.LastIndex(curPath, string(os.PathSeparator))
curPath = protoAbs[:lastIndex]
}
result = ""
return
}
func fileExist(file string) bool {
_, err := os.Stat(file)
return err == nil
}
func initGopath() string {
root, err := goPath()
if err != nil || root == "" {
log.Printf("can not read GOPATH, use ~/go as default GOPATH")
root = path.Join(os.Getenv("HOME"), "go")
}
return root
}
func goPath() (string, error) {
gopaths := strings.Split(os.Getenv("GOPATH"), ":")
if len(gopaths) == 1 {
return gopaths[0], nil
}
for _, gp := range gopaths {
absgp, err := filepath.Abs(gp)
if err != nil {
return "", err
}
if fileExist(absgp + "/src/go-common") {
return absgp, nil
}
}
return "", fmt.Errorf("can't found current gopath")
}

View File

@@ -0,0 +1,73 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
"go_test",
"go_library",
)
go_binary(
name = "protoc-gen-bm",
embed = [":go_default_library"],
tags = ["automanaged"],
)
go_test(
name = "go_default_test",
srcs = [
"command_line_test.go",
"generator_test.go",
],
embed = [":go_default_library"],
rundir = ".",
tags = ["automanaged"],
deps = [
"@com_github_golang_protobuf//proto:go_default_library",
"@com_github_golang_protobuf//protoc-gen-go/plugin:go_default_library",
],
)
go_library(
name = "go_default_library",
srcs = [
"command_line.go",
"generator.go",
"go_naming.go",
"helper.go",
"main.go",
],
importpath = "go-common/app/tool/bmproto/protoc-gen-bm",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/tool/bmproto/protoc-gen-bm/extensions/gogoproto:go_default_library",
"//app/tool/liverpc/protoc-gen-liverpc/gen:go_default_library",
"//app/tool/liverpc/protoc-gen-liverpc/gen/stringutils:go_default_library",
"//app/tool/liverpc/protoc-gen-liverpc/gen/typemap:go_default_library",
"//vendor/github.com/pkg/errors:go_default_library",
"//vendor/github.com/siddontang/go/ioutil2:go_default_library",
"//vendor/google.golang.org/genproto/googleapis/api/annotations:go_default_library",
"@com_github_golang_protobuf//proto:go_default_library",
"@com_github_golang_protobuf//protoc-gen-go/descriptor:go_default_library",
"@com_github_golang_protobuf//protoc-gen-go/plugin:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/tool/bmproto/protoc-gen-bm/example:all-srcs",
"//app/tool/bmproto/protoc-gen-bm/extensions/gogoproto:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,3 @@
# this Makefile is for old users, for new users, just go install in the 2 directories
install:
go install ; cd ../bmgen && go install ; if [ -f /usr/local/bin/bmgen ]; then rm /usr/local/bin/bmgen; fi

View File

@@ -0,0 +1,69 @@
// Copyright 2018 Twitch Interactive, Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may not
// use this file except in compliance with the License. A copy of the License is
// located at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// or in the "license" file accompanying this file. This file is distributed on
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language governing
// permissions and limitations under the License.
package main
import (
"fmt"
"strings"
)
type commandLineParams struct {
importPrefix string // String to prefix to imported package file names.
importMap map[string]string // Mapping from .proto file name to import path.
tpl bool // generate grpc compatible interface
}
// parseCommandLineParams breaks the comma-separated list of key=value pairs
// in the parameter (a member of the request protobuf) into a key/value map.
// It then sets command line parameter mappings defined by those entries.
func parseCommandLineParams(parameter string) (*commandLineParams, error) {
ps := make(map[string]string)
for _, p := range strings.Split(parameter, ",") {
if p == "" {
continue
}
i := strings.Index(p, "=")
if i < 0 {
return nil, fmt.Errorf("invalid parameter %q: expected format of parameter to be k=v", p)
}
k := p[0:i]
v := p[i+1:]
if v == "" {
return nil, fmt.Errorf("invalid parameter %q: expected format of parameter to be k=v", k)
}
ps[k] = v
}
clp := &commandLineParams{
importMap: make(map[string]string),
}
for k, v := range ps {
switch {
case k == "tpl":
if v == "true" || v == "1" {
clp.tpl = true
}
case k == "import_prefix":
clp.importPrefix = v
// Support import map 'M' prefix per https://github.com/golang/protobuf/blob/6fb5325/protoc-gen-go/generator/generator.go#L497.
case len(k) > 0 && k[0] == 'M':
clp.importMap[k[1:]] = v // 1 is the length of 'M'.
case len(k) > 0 && strings.HasPrefix(k, "go_import_mapping@"):
clp.importMap[k[18:]] = v // 18 is the length of 'go_import_mapping@'.
default:
return nil, fmt.Errorf("unknown parameter %q", k)
}
}
return clp, nil
}

View File

@@ -0,0 +1,128 @@
// Copyright 2018 Twitch Interactive, Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may not
// use this file except in compliance with the License. A copy of the License is
// located at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// or in the "license" file accompanying this file. This file is distributed on
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language governing
// permissions and limitations under the License.
package main
import (
"errors"
"reflect"
"testing"
)
func TestParseCommandLineParams(t *testing.T) {
tests := []struct {
name string
parameter string
params *commandLineParams
err error
}{
{
"no parameters",
"",
&commandLineParams{
importMap: map[string]string{},
},
nil,
},
{
"unknown parameter",
"k=v",
nil,
errors.New(`unknown parameter "k"`),
},
{
"empty parameter value - no equals sign",
"import_prefix",
nil,
errors.New(`invalid parameter "import_prefix": expected format of parameter to be k=v`),
},
{
"empty parameter value - no value",
"import_prefix=",
nil,
errors.New(`invalid parameter "import_prefix": expected format of parameter to be k=v`),
},
{
"import_prefix parameter",
"import_prefix=github.com/example/repo",
&commandLineParams{
importMap: map[string]string{},
importPrefix: "github.com/example/repo",
},
nil,
},
{
"single import parameter starting with 'M'",
"Mrpcutil/empty.proto=github.com/example/rpcutil",
&commandLineParams{
importMap: map[string]string{
"rpcutil/empty.proto": "github.com/example/rpcutil",
},
},
nil,
},
{
"multiple import parameters starting with 'M'",
"Mrpcutil/empty.proto=github.com/example/rpcutil,Mrpc/haberdasher/service.proto=github.com/example/rpc/haberdasher",
&commandLineParams{
importMap: map[string]string{
"rpcutil/empty.proto": "github.com/example/rpcutil",
"rpc/haberdasher/service.proto": "github.com/example/rpc/haberdasher",
},
},
nil,
},
{
"single import parameter starting with 'go_import_mapping@'",
"go_import_mapping@rpcutil/empty.proto=github.com/example/rpcutil",
&commandLineParams{
importMap: map[string]string{
"rpcutil/empty.proto": "github.com/example/rpcutil",
},
},
nil,
},
{
"multiple import parameters starting with 'go_import_mapping@'",
"go_import_mapping@rpcutil/empty.proto=github.com/example/rpcutil,go_import_mapping@rpc/haberdasher/service.proto=github.com/example/rpc/haberdasher",
&commandLineParams{
importMap: map[string]string{
"rpcutil/empty.proto": "github.com/example/rpcutil",
"rpc/haberdasher/service.proto": "github.com/example/rpc/haberdasher",
},
},
nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
params, err := parseCommandLineParams(tt.parameter)
switch {
case err != nil:
if tt.err == nil {
t.Fatal(err)
}
if err.Error() != tt.err.Error() {
t.Errorf("got error = %v, want %v", err, tt.err)
}
case err == nil:
if tt.err != nil {
t.Errorf("got error = %v, want %v", err, tt.err)
}
}
if !reflect.DeepEqual(params, tt.params) {
t.Errorf("got params = %v, want %v", params, tt.params)
}
})
}
}

View File

@@ -0,0 +1,65 @@
load(
"@io_bazel_rules_go//proto:def.bzl",
"go_proto_library",
)
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
proto_library(
name = "v1_proto",
srcs = ["demo.proto"],
tags = ["automanaged"],
deps = [
"@go_googleapis//google/api:annotations_proto",
"@gogo_special_proto//github.com/gogo/protobuf/gogoproto",
],
)
go_proto_library(
name = "v1_go_proto",
compilers = ["@io_bazel_rules_go//proto:gogofast_grpc"],
importpath = "go-common/app/tool/bmproto/protoc-gen-bm/example",
proto = ":v1_proto",
tags = ["automanaged"],
deps = [
"@com_github_gogo_protobuf//gogoproto:go_default_library",
"@go_googleapis//google/api:annotations_go_proto",
],
)
go_library(
name = "go_default_library",
srcs = ["demo.bm.go"],
embed = [":v1_go_proto"],
importpath = "go-common/app/tool/bmproto/protoc-gen-bm/example",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/net/http/blademaster:go_default_library",
"//library/net/http/blademaster/binding:go_default_library",
"//vendor/google.golang.org/genproto/googleapis/api/annotations:go_default_library",
"@com_github_gogo_protobuf//gogoproto:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_x_net//context:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,2 @@
generate:
protoc -I. -I${GOPATH}/src/go-common/vendor -I${GOPATH}/src --bm_out=. --gogofast_out=plugins=grpc:. demo.proto

View File

@@ -0,0 +1,166 @@
// Code generated by protoc-gen-bm v0.1, DO NOT EDIT.
// source: demo.proto
/*
Package v1 is a generated blademaster stub package.
This code was generated with go-common/app/tool/bmgen/protoc-gen-bm v0.1.
It is generated from these files:
demo.proto
*/
package v1
import (
"context"
bm "go-common/library/net/http/blademaster"
"go-common/library/net/http/blademaster/binding"
)
// to suppressed 'imported but not used warning'
var _ *bm.Context
var _ context.Context
var _ binding.StructValidator
var PathFooUnameByUid = "/xlive/demo/v1/foo/uname_by_uid_custom_route"
var PathFooGetInfo = "/live.livedemo.v1.Foo/get_info"
var PathFooUnameByUid3 = "/live.livedemo.v1.Foo/uname_by_uid3"
var PathFooUnameByUid4 = "/live.livedemo.v1.Foo/uname_by_uid4"
var PathFooGetDynamic = "/live.livedemo.v1.Foo/get_dynamic"
var PathFooNointerface = "/live.livedemo.v1.Foo/nointerface"
var PathFoo2Hello = "/live.livedemo.v1.Foo2/hello"
// =============
// Foo Interface
// =============
// Foo 相关服务
type FooBMServer interface {
// 根据uid得到uname
// `method:"post" midware:"auth,verify"`
//
// 这是详细说明
UnameByUid(ctx context.Context, req *Bar1Req) (resp *Bar1Resp, err error)
// 获取房间信息
// `midware:"guest"`
GetInfo(ctx context.Context, req *GetInfoReq) (resp *GetInfoResp, err error)
// 根据uid得到uname v3
UnameByUid3(ctx context.Context, req *Bar1Req) (resp *Bar1Resp, err error)
// test comment
// `internal:"true"`
UnameByUid4(ctx context.Context, req *Bar1Req) (resp *Bar1Resp, err error)
// `dynamic_resp:"true"`
GetDynamic(ctx context.Context, req *Bar1Req) (resp interface{}, err error)
}
var v1FooSvc FooBMServer
func fooUnameByUid(c *bm.Context) {
p := new(Bar1Req)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1FooSvc.UnameByUid(c, p)
c.JSON(resp, err)
}
func fooGetInfo(c *bm.Context) {
p := new(GetInfoReq)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1FooSvc.GetInfo(c, p)
c.JSON(resp, err)
}
func fooUnameByUid3(c *bm.Context) {
p := new(Bar1Req)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1FooSvc.UnameByUid3(c, p)
c.JSON(resp, err)
}
func fooUnameByUid4(c *bm.Context) {
p := new(Bar1Req)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1FooSvc.UnameByUid4(c, p)
c.JSON(resp, err)
}
func fooGetDynamic(c *bm.Context) {
p := new(Bar1Req)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1FooSvc.GetDynamic(c, p)
c.JSON(resp, err)
}
// RegisterV1FooService Register the blademaster route with middleware map
// midMap is the middleware map, the key is defined in proto
func RegisterV1FooService(e *bm.Engine, svc FooBMServer, midMap map[string]bm.HandlerFunc) {
auth := midMap["auth"]
guest := midMap["guest"]
verify := midMap["verify"]
v1FooSvc = svc
e.GET("/xlive/demo/v1/foo/uname_by_uid_custom_route", auth, verify, fooUnameByUid)
e.GET("/xlive/live-demo/v1/foo/get_info", guest, fooGetInfo)
e.GET("/xlive/live-demo/v1/foo/uname_by_uid3", fooUnameByUid3)
e.GET("/xlive/internal/live-demo/v1/foo/uname_by_uid4", fooUnameByUid4)
e.GET("/xlive/live-demo/v1/foo/get_dynamic", fooGetDynamic)
}
// RegisterFooBMServer Register the blademaster route
func RegisterFooBMServer(e *bm.Engine, server FooBMServer) {
e.GET("/xlive/demo/v1/foo/uname_by_uid_custom_route", fooUnameByUid)
e.GET("/live.livedemo.v1.Foo/get_info", fooGetInfo)
e.GET("/live.livedemo.v1.Foo/uname_by_uid3", fooUnameByUid3)
e.GET("/live.livedemo.v1.Foo/uname_by_uid4", fooUnameByUid4)
e.GET("/live.livedemo.v1.Foo/get_dynamic", fooGetDynamic)
}
// ==============
// Foo2 Interface
// ==============
type Foo2BMServer interface {
Hello(ctx context.Context, req *Bar1Req) (resp *Bar1Resp, err error)
}
var v1Foo2Svc Foo2BMServer
func foo2Hello(c *bm.Context) {
p := new(Bar1Req)
if err := c.BindWith(p, binding.Default(c.Request.Method, c.Request.Header.Get("Content-Type"))); err != nil {
return
}
resp, err := v1Foo2Svc.Hello(c, p)
c.JSON(resp, err)
}
// RegisterV1Foo2Service Register the blademaster route with middleware map
// midMap is the middleware map, the key is defined in proto
func RegisterV1Foo2Service(e *bm.Engine, svc Foo2BMServer, midMap map[string]bm.HandlerFunc) {
v1Foo2Svc = svc
e.GET("/xlive/live-demo/v1/foo2/hello", foo2Hello)
}
// RegisterFoo2BMServer Register the blademaster route
func RegisterFoo2BMServer(e *bm.Engine, server Foo2BMServer) {
e.GET("/live.livedemo.v1.Foo2/hello", foo2Hello)
}

View File

@@ -0,0 +1,272 @@
<!-- package=live.livedemo.v1 -->
- [/xlive/demo/v1/foo/uname_by_uid_custom_route](#xlivedemov1foouname_by_uid_custom_route) 根据uid得到uname
- [/xlive/live-demo/v1/foo/get_info](#xlivelive-demov1fooget_info) 获取房间信息
- [/xlive/live-demo/v1/foo/uname_by_uid3](#xlivelive-demov1foouname_by_uid3) 根据uid得到uname v3
- [/xlive/internal/live-demo/v1/foo/uname_by_uid4](#xliveinternallive-demov1foouname_by_uid4) test comment
- [/xlive/live-demo/v1/foo/get_dynamic](#xlivelive-demov1fooget_dynamic)
- [/xlive/live-demo/v1/foo/nointerface](#xlivelive-demov1foonointerface)
## /xlive/demo/v1/foo/uname_by_uid_custom_route
### 根据uid得到uname
这是详细说明
> 需要登录
#### 方法GET
#### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|uid|否|integer| 用户uid aaa|
#### 响应
```javascript
{
"code": 0,
"message": "ok",
"data": {
// 用户名
"uname": "hello",
// idshaha
"ids": [
343242
],
"list": [
{
"hello": "\"withquote",
"world": ""
}
],
"alist": {
"hello": "\"withquote",
"world": ""
},
"amap": {
"mapKey": {
"hello": "\"withquote",
"world": ""
}
}
}
}
```
## /xlive/live-demo/v1/foo/get_info
### 获取房间信息
#### 方法GET
#### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|room_id|是|integer| 房间id `mock:"123"|
|many_ids|否|多个integer||
#### 响应
```javascript
{
"code": 0,
"message": "ok",
"data": {
// 房间id 注释貌似只有放在前面才能被识别,放到字段声明后面是没用的
"roomid": 0,
// 用户名
"uname": "",
// 开播时间
"live_time": "",
"amap": {
"1": ""
},
"rate": 6.02214129e23,
// 用户mid
"mid": 0
}
}
```
## /xlive/live-demo/v1/foo/uname_by_uid3
### 根据uid得到uname v3
#### 方法GET
#### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|uid|否|integer| 用户uid aaa|
#### 响应
```javascript
{
"code": 0,
"message": "ok",
"data": {
// 用户名
"uname": "hello",
// idshaha
"ids": [
343242
],
"list": [
{
"hello": "\"withquote",
"world": ""
}
],
"alist": {
"hello": "\"withquote",
"world": ""
},
"amap": {
"mapKey": {
"hello": "\"withquote",
"world": ""
}
}
}
}
```
## /xlive/internal/live-demo/v1/foo/uname_by_uid4
### test comment
#### 方法GET
#### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|uid|否|integer| 用户uid aaa|
#### 响应
```javascript
{
"code": 0,
"message": "ok",
"data": {
// 用户名
"uname": "hello",
// idshaha
"ids": [
343242
],
"list": [
{
"hello": "\"withquote",
"world": ""
}
],
"alist": {
"hello": "\"withquote",
"world": ""
},
"amap": {
"mapKey": {
"hello": "\"withquote",
"world": ""
}
}
}
}
```
## /xlive/live-demo/v1/foo/get_dynamic
### 无标题
#### 方法GET
#### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|uid|否|integer| 用户uid aaa|
#### 响应
```javascript
{
"code": 0,
"message": "ok",
"data": {
// 用户名
"uname": "hello",
// idshaha
"ids": [
343242
],
"list": [
{
"hello": "\"withquote",
"world": ""
}
],
"alist": {
"hello": "\"withquote",
"world": ""
},
"amap": {
"mapKey": {
"hello": "\"withquote",
"world": ""
}
}
}
}
```
## /xlive/live-demo/v1/foo/nointerface
### 无标题
#### 方法GET
#### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|uid|否|integer| 用户uid aaa|
#### 响应
```javascript
{
"code": 0,
"message": "ok",
"data": {
// 用户名
"uname": "hello",
// idshaha
"ids": [
343242
],
"list": [
{
"hello": "\"withquote",
"world": ""
}
],
"alist": {
"hello": "\"withquote",
"world": ""
},
"amap": {
"mapKey": {
"hello": "\"withquote",
"world": ""
}
}
}
}
```

View File

@@ -0,0 +1,47 @@
<!-- package=live.livedemo.v1 -->
- [/xlive/live-demo/v1/foo2/hello](#xlivelive-demov1foo2hello)
## /xlive/live-demo/v1/foo2/hello
### 无标题
#### 方法GET
#### 请求参数
|参数名|必选|类型|描述|
|:---|:---|:---|:---|
|uid|否|integer| 用户uid aaa|
#### 响应
```javascript
{
"code": 0,
"message": "ok",
"data": {
// 用户名
"uname": "hello",
// idshaha
"ids": [
343242
],
"list": [
{
"hello": "\"withquote",
"world": ""
}
],
"alist": {
"hello": "\"withquote",
"world": ""
},
"amap": {
"mapKey": {
"hello": "\"withquote",
"world": ""
}
}
}
}
```

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,87 @@
syntax = "proto3";
package live.livedemo.v1;
option go_package = "v1";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
import "google/api/annotations.proto";
// Foo 相关服务
service Foo {
// 根据uid得到uname
// `method:"post" midware:"auth,verify"`
//
// 这是详细说明
rpc uname_by_uid (Bar1Req) returns (Bar1Resp) {
option (google.api.http) = {
get:"/xlive/demo/v1/foo/uname_by_uid_custom_route"
};
};
// 获取房间信息
// `midware:"guest"`
rpc get_info (GetInfoReq) returns (GetInfoResp);
// 根据uid得到uname v3
rpc uname_by_uid3 (Bar1Req) returns (Bar1Resp);
// test comment
// `internal:"true"`
rpc uname_by_uid4 (Bar1Req) returns (Bar1Resp);
// `dynamic_resp:"true"`
rpc get_dynamic (Bar1Req) returns (Bar1Resp);
// `dynamic:"true"`
rpc nointerface (Bar1Req) returns (Bar1Resp);
}
service Foo2 {
rpc hello (Bar1Req) returns (Bar1Resp);
}
// Bar请求
message Bar1Req {
// 用户uid
//
// aaa
int32 uid = 1 [(gogoproto.moretags) = 'form:"uid"'];
}
// Bar 相应
message Bar1Resp {
// 用户名
// `mock:"hello"`
string uname = 2 [(gogoproto.jsontag) = "uname"];
// idshaha
// `mock:"343242"`
repeated int32 ids = 3 [(gogoproto.jsontag) = "ids"];
repeated List list = 4 [(gogoproto.jsontag) = "list"];
List alist = 5 [(gogoproto.jsontag) = "alist"];
message List {
// `mock:"\"withquote"`
string hello = 1 [(gogoproto.jsontag) = "hello"];
string world = 2 [(gogoproto.jsontag) = "world"];
}
map<string, List> amap = 6 [(gogoproto.jsontag) = "amap"];
}
// 获取房间信息请求
message GetInfoReq {
// 房间id
// `mock:"123"
int64 room_id = 1 [(gogoproto.moretags) = 'form:"room_id" validate:"required"'];
repeated int64 many_ids = 2 [(gogoproto.moretags) = 'form:"many_ids"'];
}
// 获取房间信息响应
message GetInfoResp {
// 房间id 注释貌似只有放在前面才能被识别,放到字段声明后面是没用的
int64 roomid = 1 [(gogoproto.jsontag) = "roomid"]; // 这段注释不会被理会
// 用户名
string uname = 2 [(gogoproto.jsontag) = "uname"];
// 开播时间
string live_time = 3 [(gogoproto.jsontag) = "live_time"];
map<int32, string> amap = 4 [(gogoproto.jsontag) = "amap"];
// `mock:"6.02214129e23"`
float rate = 5 [(gogoproto.jsontag) = "rate"];
// 用户mid
int64 mid = 6 [(gogoproto.jsontag) = "mid"];
}

View File

@@ -0,0 +1,54 @@
load(
"@io_bazel_rules_go//proto:def.bzl",
"go_proto_library",
)
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
proto_library(
name = "gogoproto_proto",
srcs = ["gogo.proto"],
tags = ["automanaged"],
deps = ["@com_google_protobuf//:descriptor_proto"],
)
go_proto_library(
name = "gogoproto_go_proto",
compilers = ["@io_bazel_rules_go//proto:go_proto"],
importpath = "go-common/app/tool/bmproto/protoc-gen-bm/extensions/gogoproto",
proto = ":gogoproto_proto",
tags = ["automanaged"],
deps = ["@io_bazel_rules_go//proto/wkt:descriptor_go_proto"],
)
go_library(
name = "go_default_library",
srcs = [],
embed = [":gogoproto_go_proto"],
importpath = "go-common/app/tool/bmproto/protoc-gen-bm/extensions/gogoproto",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"@com_github_golang_protobuf//proto:go_default_library",
"@com_github_golang_protobuf//protoc-gen-go/descriptor:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,37 @@
# Protocol Buffers for Go with Gadgets
#
# Copyright (c) 2013, The GoGo Authors. All rights reserved.
# http://github.com/gogo/protobuf
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
regenerate:
go install github.com/golang/protobuf/protoc-gen-go
protoc --go_out=paths=source_relative:. gogo.proto
restore:
cp gogo.pb.golden gogo.pb.go
preserve:
cp gogo.pb.go gogo.pb.golden

View File

@@ -0,0 +1,818 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: gogo.proto
package gogoproto // import "go-common/app/tool/bmproto/protoc-gen-bm/extensions/gogoproto"
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import descriptor "github.com/golang/protobuf/protoc-gen-go/descriptor"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
var E_GoprotoEnumPrefix = &proto.ExtensionDesc{
ExtendedType: (*descriptor.EnumOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 62001,
Name: "gogoproto.goproto_enum_prefix",
Tag: "varint,62001,opt,name=goproto_enum_prefix,json=goprotoEnumPrefix",
Filename: "gogo.proto",
}
var E_GoprotoEnumStringer = &proto.ExtensionDesc{
ExtendedType: (*descriptor.EnumOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 62021,
Name: "gogoproto.goproto_enum_stringer",
Tag: "varint,62021,opt,name=goproto_enum_stringer,json=goprotoEnumStringer",
Filename: "gogo.proto",
}
var E_EnumStringer = &proto.ExtensionDesc{
ExtendedType: (*descriptor.EnumOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 62022,
Name: "gogoproto.enum_stringer",
Tag: "varint,62022,opt,name=enum_stringer,json=enumStringer",
Filename: "gogo.proto",
}
var E_EnumCustomname = &proto.ExtensionDesc{
ExtendedType: (*descriptor.EnumOptions)(nil),
ExtensionType: (*string)(nil),
Field: 62023,
Name: "gogoproto.enum_customname",
Tag: "bytes,62023,opt,name=enum_customname,json=enumCustomname",
Filename: "gogo.proto",
}
var E_Enumdecl = &proto.ExtensionDesc{
ExtendedType: (*descriptor.EnumOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 62024,
Name: "gogoproto.enumdecl",
Tag: "varint,62024,opt,name=enumdecl",
Filename: "gogo.proto",
}
var E_EnumvalueCustomname = &proto.ExtensionDesc{
ExtendedType: (*descriptor.EnumValueOptions)(nil),
ExtensionType: (*string)(nil),
Field: 66001,
Name: "gogoproto.enumvalue_customname",
Tag: "bytes,66001,opt,name=enumvalue_customname,json=enumvalueCustomname",
Filename: "gogo.proto",
}
var E_GoprotoGettersAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63001,
Name: "gogoproto.goproto_getters_all",
Tag: "varint,63001,opt,name=goproto_getters_all,json=goprotoGettersAll",
Filename: "gogo.proto",
}
var E_GoprotoEnumPrefixAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63002,
Name: "gogoproto.goproto_enum_prefix_all",
Tag: "varint,63002,opt,name=goproto_enum_prefix_all,json=goprotoEnumPrefixAll",
Filename: "gogo.proto",
}
var E_GoprotoStringerAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63003,
Name: "gogoproto.goproto_stringer_all",
Tag: "varint,63003,opt,name=goproto_stringer_all,json=goprotoStringerAll",
Filename: "gogo.proto",
}
var E_VerboseEqualAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63004,
Name: "gogoproto.verbose_equal_all",
Tag: "varint,63004,opt,name=verbose_equal_all,json=verboseEqualAll",
Filename: "gogo.proto",
}
var E_FaceAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63005,
Name: "gogoproto.face_all",
Tag: "varint,63005,opt,name=face_all,json=faceAll",
Filename: "gogo.proto",
}
var E_GostringAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63006,
Name: "gogoproto.gostring_all",
Tag: "varint,63006,opt,name=gostring_all,json=gostringAll",
Filename: "gogo.proto",
}
var E_PopulateAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63007,
Name: "gogoproto.populate_all",
Tag: "varint,63007,opt,name=populate_all,json=populateAll",
Filename: "gogo.proto",
}
var E_StringerAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63008,
Name: "gogoproto.stringer_all",
Tag: "varint,63008,opt,name=stringer_all,json=stringerAll",
Filename: "gogo.proto",
}
var E_OnlyoneAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63009,
Name: "gogoproto.onlyone_all",
Tag: "varint,63009,opt,name=onlyone_all,json=onlyoneAll",
Filename: "gogo.proto",
}
var E_EqualAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63013,
Name: "gogoproto.equal_all",
Tag: "varint,63013,opt,name=equal_all,json=equalAll",
Filename: "gogo.proto",
}
var E_DescriptionAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63014,
Name: "gogoproto.description_all",
Tag: "varint,63014,opt,name=description_all,json=descriptionAll",
Filename: "gogo.proto",
}
var E_TestgenAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63015,
Name: "gogoproto.testgen_all",
Tag: "varint,63015,opt,name=testgen_all,json=testgenAll",
Filename: "gogo.proto",
}
var E_BenchgenAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63016,
Name: "gogoproto.benchgen_all",
Tag: "varint,63016,opt,name=benchgen_all,json=benchgenAll",
Filename: "gogo.proto",
}
var E_MarshalerAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63017,
Name: "gogoproto.marshaler_all",
Tag: "varint,63017,opt,name=marshaler_all,json=marshalerAll",
Filename: "gogo.proto",
}
var E_UnmarshalerAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63018,
Name: "gogoproto.unmarshaler_all",
Tag: "varint,63018,opt,name=unmarshaler_all,json=unmarshalerAll",
Filename: "gogo.proto",
}
var E_StableMarshalerAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63019,
Name: "gogoproto.stable_marshaler_all",
Tag: "varint,63019,opt,name=stable_marshaler_all,json=stableMarshalerAll",
Filename: "gogo.proto",
}
var E_SizerAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63020,
Name: "gogoproto.sizer_all",
Tag: "varint,63020,opt,name=sizer_all,json=sizerAll",
Filename: "gogo.proto",
}
var E_GoprotoEnumStringerAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63021,
Name: "gogoproto.goproto_enum_stringer_all",
Tag: "varint,63021,opt,name=goproto_enum_stringer_all,json=goprotoEnumStringerAll",
Filename: "gogo.proto",
}
var E_EnumStringerAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63022,
Name: "gogoproto.enum_stringer_all",
Tag: "varint,63022,opt,name=enum_stringer_all,json=enumStringerAll",
Filename: "gogo.proto",
}
var E_UnsafeMarshalerAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63023,
Name: "gogoproto.unsafe_marshaler_all",
Tag: "varint,63023,opt,name=unsafe_marshaler_all,json=unsafeMarshalerAll",
Filename: "gogo.proto",
}
var E_UnsafeUnmarshalerAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63024,
Name: "gogoproto.unsafe_unmarshaler_all",
Tag: "varint,63024,opt,name=unsafe_unmarshaler_all,json=unsafeUnmarshalerAll",
Filename: "gogo.proto",
}
var E_GoprotoExtensionsMapAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63025,
Name: "gogoproto.goproto_extensions_map_all",
Tag: "varint,63025,opt,name=goproto_extensions_map_all,json=goprotoExtensionsMapAll",
Filename: "gogo.proto",
}
var E_GoprotoUnrecognizedAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63026,
Name: "gogoproto.goproto_unrecognized_all",
Tag: "varint,63026,opt,name=goproto_unrecognized_all,json=goprotoUnrecognizedAll",
Filename: "gogo.proto",
}
var E_GogoprotoImport = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63027,
Name: "gogoproto.gogoproto_import",
Tag: "varint,63027,opt,name=gogoproto_import,json=gogoprotoImport",
Filename: "gogo.proto",
}
var E_ProtosizerAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63028,
Name: "gogoproto.protosizer_all",
Tag: "varint,63028,opt,name=protosizer_all,json=protosizerAll",
Filename: "gogo.proto",
}
var E_CompareAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63029,
Name: "gogoproto.compare_all",
Tag: "varint,63029,opt,name=compare_all,json=compareAll",
Filename: "gogo.proto",
}
var E_TypedeclAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63030,
Name: "gogoproto.typedecl_all",
Tag: "varint,63030,opt,name=typedecl_all,json=typedeclAll",
Filename: "gogo.proto",
}
var E_EnumdeclAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63031,
Name: "gogoproto.enumdecl_all",
Tag: "varint,63031,opt,name=enumdecl_all,json=enumdeclAll",
Filename: "gogo.proto",
}
var E_GoprotoRegistration = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63032,
Name: "gogoproto.goproto_registration",
Tag: "varint,63032,opt,name=goproto_registration,json=goprotoRegistration",
Filename: "gogo.proto",
}
var E_MessagenameAll = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FileOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 63033,
Name: "gogoproto.messagename_all",
Tag: "varint,63033,opt,name=messagename_all,json=messagenameAll",
Filename: "gogo.proto",
}
var E_GoprotoGetters = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64001,
Name: "gogoproto.goproto_getters",
Tag: "varint,64001,opt,name=goproto_getters,json=goprotoGetters",
Filename: "gogo.proto",
}
var E_GoprotoStringer = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64003,
Name: "gogoproto.goproto_stringer",
Tag: "varint,64003,opt,name=goproto_stringer,json=goprotoStringer",
Filename: "gogo.proto",
}
var E_VerboseEqual = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64004,
Name: "gogoproto.verbose_equal",
Tag: "varint,64004,opt,name=verbose_equal,json=verboseEqual",
Filename: "gogo.proto",
}
var E_Face = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64005,
Name: "gogoproto.face",
Tag: "varint,64005,opt,name=face",
Filename: "gogo.proto",
}
var E_Gostring = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64006,
Name: "gogoproto.gostring",
Tag: "varint,64006,opt,name=gostring",
Filename: "gogo.proto",
}
var E_Populate = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64007,
Name: "gogoproto.populate",
Tag: "varint,64007,opt,name=populate",
Filename: "gogo.proto",
}
var E_Stringer = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 67008,
Name: "gogoproto.stringer",
Tag: "varint,67008,opt,name=stringer",
Filename: "gogo.proto",
}
var E_Onlyone = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64009,
Name: "gogoproto.onlyone",
Tag: "varint,64009,opt,name=onlyone",
Filename: "gogo.proto",
}
var E_Equal = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64013,
Name: "gogoproto.equal",
Tag: "varint,64013,opt,name=equal",
Filename: "gogo.proto",
}
var E_Description = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64014,
Name: "gogoproto.description",
Tag: "varint,64014,opt,name=description",
Filename: "gogo.proto",
}
var E_Testgen = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64015,
Name: "gogoproto.testgen",
Tag: "varint,64015,opt,name=testgen",
Filename: "gogo.proto",
}
var E_Benchgen = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64016,
Name: "gogoproto.benchgen",
Tag: "varint,64016,opt,name=benchgen",
Filename: "gogo.proto",
}
var E_Marshaler = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64017,
Name: "gogoproto.marshaler",
Tag: "varint,64017,opt,name=marshaler",
Filename: "gogo.proto",
}
var E_Unmarshaler = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64018,
Name: "gogoproto.unmarshaler",
Tag: "varint,64018,opt,name=unmarshaler",
Filename: "gogo.proto",
}
var E_StableMarshaler = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64019,
Name: "gogoproto.stable_marshaler",
Tag: "varint,64019,opt,name=stable_marshaler,json=stableMarshaler",
Filename: "gogo.proto",
}
var E_Sizer = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64020,
Name: "gogoproto.sizer",
Tag: "varint,64020,opt,name=sizer",
Filename: "gogo.proto",
}
var E_UnsafeMarshaler = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64023,
Name: "gogoproto.unsafe_marshaler",
Tag: "varint,64023,opt,name=unsafe_marshaler,json=unsafeMarshaler",
Filename: "gogo.proto",
}
var E_UnsafeUnmarshaler = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64024,
Name: "gogoproto.unsafe_unmarshaler",
Tag: "varint,64024,opt,name=unsafe_unmarshaler,json=unsafeUnmarshaler",
Filename: "gogo.proto",
}
var E_GoprotoExtensionsMap = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64025,
Name: "gogoproto.goproto_extensions_map",
Tag: "varint,64025,opt,name=goproto_extensions_map,json=goprotoExtensionsMap",
Filename: "gogo.proto",
}
var E_GoprotoUnrecognized = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64026,
Name: "gogoproto.goproto_unrecognized",
Tag: "varint,64026,opt,name=goproto_unrecognized,json=goprotoUnrecognized",
Filename: "gogo.proto",
}
var E_Protosizer = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64028,
Name: "gogoproto.protosizer",
Tag: "varint,64028,opt,name=protosizer",
Filename: "gogo.proto",
}
var E_Compare = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64029,
Name: "gogoproto.compare",
Tag: "varint,64029,opt,name=compare",
Filename: "gogo.proto",
}
var E_Typedecl = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64030,
Name: "gogoproto.typedecl",
Tag: "varint,64030,opt,name=typedecl",
Filename: "gogo.proto",
}
var E_Messagename = &proto.ExtensionDesc{
ExtendedType: (*descriptor.MessageOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 64033,
Name: "gogoproto.messagename",
Tag: "varint,64033,opt,name=messagename",
Filename: "gogo.proto",
}
var E_Nullable = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FieldOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 65001,
Name: "gogoproto.nullable",
Tag: "varint,65001,opt,name=nullable",
Filename: "gogo.proto",
}
var E_Embed = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FieldOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 65002,
Name: "gogoproto.embed",
Tag: "varint,65002,opt,name=embed",
Filename: "gogo.proto",
}
var E_Customtype = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FieldOptions)(nil),
ExtensionType: (*string)(nil),
Field: 65003,
Name: "gogoproto.customtype",
Tag: "bytes,65003,opt,name=customtype",
Filename: "gogo.proto",
}
var E_Customname = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FieldOptions)(nil),
ExtensionType: (*string)(nil),
Field: 65004,
Name: "gogoproto.customname",
Tag: "bytes,65004,opt,name=customname",
Filename: "gogo.proto",
}
var E_Jsontag = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FieldOptions)(nil),
ExtensionType: (*string)(nil),
Field: 65005,
Name: "gogoproto.jsontag",
Tag: "bytes,65005,opt,name=jsontag",
Filename: "gogo.proto",
}
var E_Moretags = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FieldOptions)(nil),
ExtensionType: (*string)(nil),
Field: 65006,
Name: "gogoproto.moretags",
Tag: "bytes,65006,opt,name=moretags",
Filename: "gogo.proto",
}
var E_Casttype = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FieldOptions)(nil),
ExtensionType: (*string)(nil),
Field: 65007,
Name: "gogoproto.casttype",
Tag: "bytes,65007,opt,name=casttype",
Filename: "gogo.proto",
}
var E_Castkey = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FieldOptions)(nil),
ExtensionType: (*string)(nil),
Field: 65008,
Name: "gogoproto.castkey",
Tag: "bytes,65008,opt,name=castkey",
Filename: "gogo.proto",
}
var E_Castvalue = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FieldOptions)(nil),
ExtensionType: (*string)(nil),
Field: 65009,
Name: "gogoproto.castvalue",
Tag: "bytes,65009,opt,name=castvalue",
Filename: "gogo.proto",
}
var E_Stdtime = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FieldOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 65010,
Name: "gogoproto.stdtime",
Tag: "varint,65010,opt,name=stdtime",
Filename: "gogo.proto",
}
var E_Stdduration = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FieldOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 65011,
Name: "gogoproto.stdduration",
Tag: "varint,65011,opt,name=stdduration",
Filename: "gogo.proto",
}
func init() {
proto.RegisterExtension(E_GoprotoEnumPrefix)
proto.RegisterExtension(E_GoprotoEnumStringer)
proto.RegisterExtension(E_EnumStringer)
proto.RegisterExtension(E_EnumCustomname)
proto.RegisterExtension(E_Enumdecl)
proto.RegisterExtension(E_EnumvalueCustomname)
proto.RegisterExtension(E_GoprotoGettersAll)
proto.RegisterExtension(E_GoprotoEnumPrefixAll)
proto.RegisterExtension(E_GoprotoStringerAll)
proto.RegisterExtension(E_VerboseEqualAll)
proto.RegisterExtension(E_FaceAll)
proto.RegisterExtension(E_GostringAll)
proto.RegisterExtension(E_PopulateAll)
proto.RegisterExtension(E_StringerAll)
proto.RegisterExtension(E_OnlyoneAll)
proto.RegisterExtension(E_EqualAll)
proto.RegisterExtension(E_DescriptionAll)
proto.RegisterExtension(E_TestgenAll)
proto.RegisterExtension(E_BenchgenAll)
proto.RegisterExtension(E_MarshalerAll)
proto.RegisterExtension(E_UnmarshalerAll)
proto.RegisterExtension(E_StableMarshalerAll)
proto.RegisterExtension(E_SizerAll)
proto.RegisterExtension(E_GoprotoEnumStringerAll)
proto.RegisterExtension(E_EnumStringerAll)
proto.RegisterExtension(E_UnsafeMarshalerAll)
proto.RegisterExtension(E_UnsafeUnmarshalerAll)
proto.RegisterExtension(E_GoprotoExtensionsMapAll)
proto.RegisterExtension(E_GoprotoUnrecognizedAll)
proto.RegisterExtension(E_GogoprotoImport)
proto.RegisterExtension(E_ProtosizerAll)
proto.RegisterExtension(E_CompareAll)
proto.RegisterExtension(E_TypedeclAll)
proto.RegisterExtension(E_EnumdeclAll)
proto.RegisterExtension(E_GoprotoRegistration)
proto.RegisterExtension(E_MessagenameAll)
proto.RegisterExtension(E_GoprotoGetters)
proto.RegisterExtension(E_GoprotoStringer)
proto.RegisterExtension(E_VerboseEqual)
proto.RegisterExtension(E_Face)
proto.RegisterExtension(E_Gostring)
proto.RegisterExtension(E_Populate)
proto.RegisterExtension(E_Stringer)
proto.RegisterExtension(E_Onlyone)
proto.RegisterExtension(E_Equal)
proto.RegisterExtension(E_Description)
proto.RegisterExtension(E_Testgen)
proto.RegisterExtension(E_Benchgen)
proto.RegisterExtension(E_Marshaler)
proto.RegisterExtension(E_Unmarshaler)
proto.RegisterExtension(E_StableMarshaler)
proto.RegisterExtension(E_Sizer)
proto.RegisterExtension(E_UnsafeMarshaler)
proto.RegisterExtension(E_UnsafeUnmarshaler)
proto.RegisterExtension(E_GoprotoExtensionsMap)
proto.RegisterExtension(E_GoprotoUnrecognized)
proto.RegisterExtension(E_Protosizer)
proto.RegisterExtension(E_Compare)
proto.RegisterExtension(E_Typedecl)
proto.RegisterExtension(E_Messagename)
proto.RegisterExtension(E_Nullable)
proto.RegisterExtension(E_Embed)
proto.RegisterExtension(E_Customtype)
proto.RegisterExtension(E_Customname)
proto.RegisterExtension(E_Jsontag)
proto.RegisterExtension(E_Moretags)
proto.RegisterExtension(E_Casttype)
proto.RegisterExtension(E_Castkey)
proto.RegisterExtension(E_Castvalue)
proto.RegisterExtension(E_Stdtime)
proto.RegisterExtension(E_Stdduration)
}
func init() { proto.RegisterFile("gogo.proto", fileDescriptor_gogo_035fd4fcfeb21e86) }
var fileDescriptor_gogo_035fd4fcfeb21e86 = []byte{
// 1264 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x98, 0x49, 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 0x38, 0x6e, 0x6c, 0x62, 0xff, 0x22, 0xb6, 0x00, 0x10, 0x6e, 0x3a, 0x71, 0x62, 0xf3,
0xde, 0x7f, 0x33, 0xcc, 0x00, 0x6e, 0x1a, 0x9f, 0x1f, 0x95, 0x5b, 0x26, 0xf6, 0x1f, 0xde, 0x34,
0xad, 0x17, 0xf3, 0x50, 0xc1, 0xc7, 0xec, 0x5b, 0x11, 0x13, 0xfc, 0x2f, 0xc1, 0x1d, 0x02, 0xff,
0x73, 0x9c, 0xb4, 0x92, 0xb6, 0x39, 0xd8, 0xff, 0x51, 0xa6, 0x79, 0xbd, 0x58, 0x84, 0xe1, 0x38,
0x69, 0xb5, 0x52, 0x9a, 0xaf, 0x0c, 0xf8, 0xff, 0xbb, 0xc5, 0x47, 0xee, 0x82, 0x39, 0xf2, 0x30,
0x4c, 0x36, 0x95, 0xdf, 0x0d, 0x1e, 0x81, 0x15, 0xb5, 0xa2, 0xd6, 0xb2, 0xab, 0xf8, 0xe0, 0xbc,
0xab, 0x66, 0x9a, 0xca, 0xf7, 0x55, 0x50, 0x73, 0xc2, 0xb0, 0x96, 0x28, 0xe5, 0xd5, 0x1a, 0x7e,
0xb6, 0x34, 0xff, 0x6a, 0xaf, 0x39, 0xe3, 0xca, 0x60, 0xa6, 0xe1, 0xd7, 0x3a, 0x75, 0xa9, 0x56,
0x4c, 0xc8, 0x57, 0x03, 0x00, 0x00, 0xff, 0xff, 0x24, 0x56, 0x45, 0x84, 0x1d, 0x14, 0x00, 0x00,
}

View File

@@ -0,0 +1,45 @@
// Code generated by protoc-gen-go.
// source: gogo.proto
// DO NOT EDIT!
package gogoproto
import proto "github.com/gogo/protobuf/proto"
import json "encoding/json"
import math "math"
import google_protobuf "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
// Reference proto, json, and math imports to suppress error if they are not otherwise used.
var _ = proto.Marshal
var _ = &json.SyntaxError{}
var _ = math.Inf
var E_Nullable = &proto.ExtensionDesc{
ExtendedType: (*google_protobuf.FieldOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 51235,
Name: "gogoproto.nullable",
Tag: "varint,51235,opt,name=nullable",
}
var E_Embed = &proto.ExtensionDesc{
ExtendedType: (*google_protobuf.FieldOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 51236,
Name: "gogoproto.embed",
Tag: "varint,51236,opt,name=embed",
}
var E_Customtype = &proto.ExtensionDesc{
ExtendedType: (*google_protobuf.FieldOptions)(nil),
ExtensionType: (*string)(nil),
Field: 51237,
Name: "gogoproto.customtype",
Tag: "bytes,51237,opt,name=customtype",
}
func init() {
proto.RegisterExtension(E_Nullable)
proto.RegisterExtension(E_Embed)
proto.RegisterExtension(E_Customtype)
}

View File

@@ -0,0 +1,136 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
syntax = "proto2";
package gogoproto;
import "google/protobuf/descriptor.proto";
option java_package = "com.google.protobuf";
option java_outer_classname = "GoGoProtos";
option go_package = "go-common/app/tool/bmproto/protoc-gen-bm/extensions/gogoproto";
extend google.protobuf.EnumOptions {
optional bool goproto_enum_prefix = 62001;
optional bool goproto_enum_stringer = 62021;
optional bool enum_stringer = 62022;
optional string enum_customname = 62023;
optional bool enumdecl = 62024;
}
extend google.protobuf.EnumValueOptions {
optional string enumvalue_customname = 66001;
}
extend google.protobuf.FileOptions {
optional bool goproto_getters_all = 63001;
optional bool goproto_enum_prefix_all = 63002;
optional bool goproto_stringer_all = 63003;
optional bool verbose_equal_all = 63004;
optional bool face_all = 63005;
optional bool gostring_all = 63006;
optional bool populate_all = 63007;
optional bool stringer_all = 63008;
optional bool onlyone_all = 63009;
optional bool equal_all = 63013;
optional bool description_all = 63014;
optional bool testgen_all = 63015;
optional bool benchgen_all = 63016;
optional bool marshaler_all = 63017;
optional bool unmarshaler_all = 63018;
optional bool stable_marshaler_all = 63019;
optional bool sizer_all = 63020;
optional bool goproto_enum_stringer_all = 63021;
optional bool enum_stringer_all = 63022;
optional bool unsafe_marshaler_all = 63023;
optional bool unsafe_unmarshaler_all = 63024;
optional bool goproto_extensions_map_all = 63025;
optional bool goproto_unrecognized_all = 63026;
optional bool gogoproto_import = 63027;
optional bool protosizer_all = 63028;
optional bool compare_all = 63029;
optional bool typedecl_all = 63030;
optional bool enumdecl_all = 63031;
optional bool goproto_registration = 63032;
optional bool messagename_all = 63033;
}
extend google.protobuf.MessageOptions {
optional bool goproto_getters = 64001;
optional bool goproto_stringer = 64003;
optional bool verbose_equal = 64004;
optional bool face = 64005;
optional bool gostring = 64006;
optional bool populate = 64007;
optional bool stringer = 67008;
optional bool onlyone = 64009;
optional bool equal = 64013;
optional bool description = 64014;
optional bool testgen = 64015;
optional bool benchgen = 64016;
optional bool marshaler = 64017;
optional bool unmarshaler = 64018;
optional bool stable_marshaler = 64019;
optional bool sizer = 64020;
optional bool unsafe_marshaler = 64023;
optional bool unsafe_unmarshaler = 64024;
optional bool goproto_extensions_map = 64025;
optional bool goproto_unrecognized = 64026;
optional bool protosizer = 64028;
optional bool compare = 64029;
optional bool typedecl = 64030;
optional bool messagename = 64033;
}
extend google.protobuf.FieldOptions {
optional bool nullable = 65001;
optional bool embed = 65002;
optional string customtype = 65003;
optional string customname = 65004;
optional string jsontag = 65005;
optional string moretags = 65006;
optional string casttype = 65007;
optional string castkey = 65008;
optional string castvalue = 65009;
optional bool stdtime = 65010;
optional bool stdduration = 65011;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,40 @@
// Copyright 2018 Twitch Interactive, Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may not
// use this file except in compliance with the License. A copy of the License is
// located at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// or in the "license" file accompanying this file. This file is distributed on
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language governing
// permissions and limitations under the License.
package main
import (
"os"
"os/exec"
"testing"
"github.com/golang/protobuf/proto"
plugin "github.com/golang/protobuf/protoc-gen-go/plugin"
)
func TestGenerateParseCommandLineParamsError(t *testing.T) {
if os.Getenv("BE_CRASHER") == "1" {
g := &bm{}
g.Generate(&plugin.CodeGeneratorRequest{
Parameter: proto.String("invalid"),
})
return
}
cmd := exec.Command(os.Args[0], "-test.run=TestGenerateParseCommandLineParamsError")
cmd.Env = append(os.Environ(), "BE_CRASHER=1")
err := cmd.Run()
if e, ok := err.(*exec.ExitError); ok && !e.Success() {
return
}
t.Fatalf("process ran with err %v, want exit status 1", err)
}

View File

@@ -0,0 +1,86 @@
// Copyright 2018 Twitch Interactive, Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may not
// use this file except in compliance with the License. A copy of the License is
// located at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// or in the "license" file accompanying this file. This file is distributed on
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language governing
// permissions and limitations under the License.
package main
import (
"path"
"strings"
"go-common/app/tool/liverpc/protoc-gen-liverpc/gen/stringutils"
"github.com/golang/protobuf/protoc-gen-go/descriptor"
)
// goPackageOption interprets the file's go_package option.
// If there is no go_package, it returns ("", "", false).
// If there's a simple name, it returns ("", pkg, true).
// If the option implies an import path, it returns (impPath, pkg, true).
func goPackageOption(f *descriptor.FileDescriptorProto) (impPath, pkg string, ok bool) {
pkg = f.GetOptions().GetGoPackage()
if pkg == "" {
return
}
ok = true
// The presence of a slash implies there's an import path.
slash := strings.LastIndex(pkg, "/")
if slash < 0 {
return
}
impPath, pkg = pkg, pkg[slash+1:]
// A semicolon-delimited suffix overrides the package name.
sc := strings.IndexByte(impPath, ';')
if sc < 0 {
return
}
impPath, pkg = impPath[:sc], impPath[sc+1:]
return
}
// goPackageName returns the Go package name to use in the generated Go file.
// The result explicitly reports whether the name came from an option go_package
// statement. If explicit is false, the name was derived from the protocol
// buffer's package statement or the input file name.
func goPackageName(f *descriptor.FileDescriptorProto) (name string, explicit bool) {
// Does the file have a "go_package" option?
if _, pkg, ok := goPackageOption(f); ok {
return pkg, true
}
// Does the file have a package clause?
if pkg := f.GetPackage(); pkg != "" {
return pkg, false
}
// Use the file base name.
return stringutils.BaseName(f.GetName()), false
}
// goFileName returns the output name for the generated Go file.
func goFileName(f *descriptor.FileDescriptorProto, suffix string) string {
name := *f.Name
if ext := path.Ext(name); ext == ".pb" || ext == ".proto" || ext == ".protodevel" {
name = name[:len(name)-len(ext)]
}
name += suffix
// Does the file have a "go_package" option? If it does, it may override the
// filename.
if impPath, _, ok := goPackageOption(f); ok && impPath != "" {
// Replace the existing dirname with the declared import path.
_, name = path.Split(name)
name = path.Join(impPath, name)
return name
}
return name
}

View File

@@ -0,0 +1,86 @@
package main
import (
"fmt"
"net/http"
"strings"
"go-common/app/tool/bmproto/protoc-gen-bm/extensions/gogoproto"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/protoc-gen-go/descriptor"
"google.golang.org/genproto/googleapis/api/annotations"
)
func getMoreTags(field *descriptor.FieldDescriptorProto) *string {
if field == nil {
return nil
}
if field.Options != nil {
v, err := proto.GetExtension(field.Options, gogoproto.E_Moretags)
if err == nil && v.(*string) != nil {
return v.(*string)
}
}
return nil
}
func getJsonTag(field *descriptor.FieldDescriptorProto) string {
if field == nil {
return ""
}
if field.Options != nil {
v, err := proto.GetExtension(field.Options, gogoproto.E_Jsontag)
if err == nil && v.(*string) != nil {
ret := *(v.(*string))
i := strings.Index(ret, ",")
if i != -1 {
ret = ret[:i]
}
return ret
}
}
return field.GetName()
}
type googleMethodOptionInfo struct {
Method string
PathPattern string
HTTPRule *annotations.HttpRule
}
// ParseBMMethod parse BMMethodDescriptor form method descriptor proto
func ParseBMMethod(method *descriptor.MethodDescriptorProto) (*googleMethodOptionInfo, error) {
ext, err := proto.GetExtension(method.GetOptions(), annotations.E_Http)
if err != nil {
return nil, fmt.Errorf("get extension error: %s", err)
}
rule := ext.(*annotations.HttpRule)
var httpMethod string
var pathPattern string
switch pattern := rule.Pattern.(type) {
case *annotations.HttpRule_Get:
pathPattern = pattern.Get
httpMethod = http.MethodGet
case *annotations.HttpRule_Put:
pathPattern = pattern.Put
httpMethod = http.MethodPut
case *annotations.HttpRule_Post:
pathPattern = pattern.Post
httpMethod = http.MethodPost
case *annotations.HttpRule_Patch:
pathPattern = pattern.Patch
httpMethod = http.MethodPatch
case *annotations.HttpRule_Delete:
pathPattern = pattern.Delete
httpMethod = http.MethodDelete
default:
return nil, fmt.Errorf("unsupport http pattern %s", rule.Pattern)
}
bmMethod := &googleMethodOptionInfo{
Method: httpMethod,
PathPattern: pathPattern,
HTTPRule: rule,
}
return bmMethod, nil
}

View File

@@ -0,0 +1,34 @@
// Copyright 2018 Twitch Interactive, Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may not
// use this file except in compliance with the License. A copy of the License is
// located at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// or in the "license" file accompanying this file. This file is distributed on
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language governing
// permissions and limitations under the License.
package main
import (
"flag"
"fmt"
"os"
"go-common/app/tool/liverpc/protoc-gen-liverpc/gen"
)
func main() {
versionFlag := flag.Bool("version", false, "print version and exit")
flag.Parse()
if *versionFlag {
fmt.Println(gen.Version)
os.Exit(0)
}
g := bmGenerator()
gen.Main(g)
}