gen

package
v1.1.37 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

You can use the "packr clean" command to clean up this, and any other packr generated files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseProtos added in v1.1.14

func ParseProtos(protos []string) ([]*Service, []*Message)

Types

type API

type API struct {
	Name   string
	Desc   string
	Method string
	URL    string
	// Target file is the go file where it should be generated.
	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 {
	// contains filtered or unexported fields
}

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

func NewGenerator

func NewGenerator(module, protoPath, pbPath, controllerRoot, routerFile string) *Generator

New returns a new instance of Generator.

func (*Generator) Gen added in v1.1.14

func (c *Generator) Gen(protos []string) error

func (*Generator) GenController added in v1.1.14

func (g *Generator) GenController(protos []string) error

生成controller

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
	File         string
	APIs         []*API
}

Service represents a service definition is a proto file.

type Target

type Target struct {
	PackageName string
	TargetFile  string
}

Jump to

Keyboard shortcuts

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