pbgen

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &cli.Command{
	Name:   "pbgen",
	Usage:  "根据 proto 文件生成代码",
	Flags:  flags,
	Action: action,
}

Command 定义了 pbgen 子命令,用于根据 proto 文件生成代码

Functions

This section is empty.

Types

type Enum

type Enum struct {
	Name    string      // 枚举名称
	Values  []EnumValue // 枚举值列表
	Comment string      // 注释
}

Enum 表示枚举类型定义

type EnumValue

type EnumValue struct {
	Name    string // 枚举值名称
	Number  int    // 枚举值
	Comment string // 注释
}

EnumValue 表示枚举值

type Field

type Field struct {
	Name    string // 字段名称
	Type    string // 字段类型
	IsArray bool   // 是否是数组类型
	Comment string // 字段注释
	IsEnum  bool   // 是否是枚举类型
}

Field 表示 protobuf 消息中的字段定义

type Message

type Message struct {
	Name    string  // 消息名称
	Fields  []Field // 消息包含的字段列表
	Comment string  // 消息注释
}

Message 表示 protobuf 消息定义

type Method

type Method struct {
	Name       string   // 方法名称
	FieldName  string   // 字段名称(小写)
	InputType  string   // 输入参数类型
	OutputType string   // 输出参数类型
	HTTPPath   string   // HTTP 路径
	Comment    string   // 方法注释
	Request    *Message // 请求消息类型
	Response   *Message // 响应消息类型
}

Method 表示 protobuf 服务中的方法定义

type PbInfo

type PbInfo struct {
	ProtoFile       string              // proto 文件路径
	Package         string              // proto 包名
	ServiceName     string              // 服务名称
	Methods         []Method            // 服务方法列表
	GoPackage       string              // go 包路径
	GoModPath       string              // go mod 路径
	EndpointPath    string              // endpoint 代码生成路径
	PkgName         string              // go_package 的最后一个路径
	EndpointPkgName string              // endpoint 包名,使用 epath 的最后一个路径
	Messages        map[string]*Message // 消息类型映射表
	Enums           map[string]*Enum    // 枚举类型映射表
}

PbInfo 包含解析 proto 文件后的所有信息

Jump to

Keyboard shortcuts

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