gen

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const ControllerStr = "controller"

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Name       string
	Desc       string
	Method     string
	URL        string
	TargetFile string
	Request    *Message
	Response   *Message
}

API represents a rpc definition in a proto file, corresponding to a gin controller.

type Controller

type Controller struct {
	Module      string
	PackageName string // 包名
	PbPath      string // pb文件路径
	Import      string // pb文件import
	Func        ControllerFunc
}

type ControllerFunc

type ControllerFunc struct {
	Name     string // 函数名称
	Desc     string // 函数描述
	Request  string // 函数请求
	Response string // 函数返回
}

type Field

type Field struct {
	Name          string
	InlineComment string
}

Field represents a field definition in a proto message. We only need its inline comment to modify go tags so we don't parse the comment.

type FileInfo

type FileInfo struct {
	TemplateURL string
	TargetURL   string
	Content     string
}

type Generator

type Generator struct {
	GoModule   string
	ProtoPath  string
	ProtoFiles []string
	PbPath     string

	PbFiles        []string
	ControllerPath string
	RouterFile     string
	ThirdPartyPath []string
	SwaggerPath    string
	ServiceNodeMap map[string]string
	// contains filtered or unexported fields
}

Generator is responsible to init project and generates codes from proto.

var (
	Gender *Generator
)

func (*Generator) FormatSwaggerFile added in v1.0.3

func (g *Generator) FormatSwaggerFile() error

FormatSwaggerFile 编辑 api/swagger.json的info.description

func (*Generator) GenController added in v1.0.3

func (g *Generator) GenController() error

GenController 生产controller

func (*Generator) HandlePbDir added in v1.0.3

func (g *Generator) HandlePbDir() error

HandlePbDir 处理pb文件夹

func (*Generator) HandleTagGen added in v1.0.3

func (g *Generator) HandleTagGen() error

HandleTagGen 使用inject_tag处理pb的tag : github.com/favadi/protoc-go-inject-tag

func (*Generator) Run added in v1.0.3

func (g *Generator) Run() error

func (*Generator) WithServiceNodeMap

func (g *Generator) WithServiceNodeMap(m map[string]string) *Generator

WithServiceNodeMap 获取service名称map

type Message

type Message struct {
	Name string
	// File is the proto file where it's defined.
	File   string
	Fields []*Field
}

Message represents a message definition in a proto file.

type Project

type Project struct {
	ProjectName   string
	ProjectModule string
}

func (*Project) GenerateTemplateFile

func (p *Project) GenerateTemplateFile(file *FileInfo) error

type Service

type Service struct {
	PackageName  string // 包名
	PackageAlias string // 包名别名
	Name         string // service名称
	File         string // proto文件url
	APIs         []*API // 接口
	NodeName     string // 注释名称
}

Service represents a service definition is a proto file.

type Target

type Target struct {
	PackageName string
	TargetFile  string
	NodeName    string
}

Jump to

Keyboard shortcuts

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