gen

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: Apache-2.0 Imports: 10 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文件路径
	PbAlias     string // pb别名
	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 added in v1.1.14

type Generator struct {
	GoModule       string
	ProtoPath      string
	ProtoFiles     []string
	PbPath         string
	PbAlias        string
	PbFiles        []string
	ControllerPath string
	RouterFile     string
	ThirdPartyPath string
	SdkPath        string
	SwaggerPath    string
	ServiceNodeMap map[string]string
}

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

var (
	Gener *Generator
)

func NewGenerator

func NewGenerator(gener *Generator) *Generator

New returns a new instance of Generator.

func (*Generator) Gen added in v1.1.14

func (g *Generator) Gen() error

func (*Generator) WithServiceNodeMap added in v1.3.0

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

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