protoc-gen-go-aithu-tables

command module
v2.0.0-...-dd4f76f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

README

protoc-gen-go-aithu-tables

错误码表格生成

安装工具

# 如果电脑中没有protoc-gen-go需要先安装
# go install google.golang.org/protobuf/cmd/protoc-gen-go
go install gitee.com/dhcy/aithu-protoc/cmd/protoc-gen-go-aithu-tables/v2@latest
# 或者
go get -u gitee.com/dhcy/aithu-protoc/cmd/protoc-gen-go-aithu-tables/v2@latest

错误定义

syntax = "proto3";

package database.v1;

option go_package = "pb/database/service/v1;v1";

// +source=system
// +module=01
// DatabaseReason 数据库状态
enum DatabaseReason{
  DATABASE_NONE = 0;
  // 数据不存在 +deprecated
  ERROR_NOT_FOUND = 1;
  // 数据库连接超时
  INFO_CONNECT_TIMEOUT = 2;
}

注意事项:

  • +source=来源 +module=模块号 根据实际业务需求填写
  • 协议定义格式为Typ(ERROR,INFO,WARN)_具体错误详情这种格式定义,如ERROR_NOT_FOUND
  • 第0个协议作为保留,会跳过,其他协议注注释协议号必须明确,没有将抛出异常
  • 协议号不允许重复,默认范围为1-99999这个区间,超出范围将抛出异常
  • 如果一个协议需要废弃,但可能还在使用,只需要在注释中标明+deprecated废弃标识即可

错误生成

通过proto生成对于的代码:

protoc --proto_path=. \
         --go_out=paths=source_relative:. \
         --go-aithu-tables_out=paths=source_relative:. \
         $(PB_PROTO_FILES)

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL