parse

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package parse is parsed proto file to struct

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetImportPkg

func GetImportPkg(services []*PbService) []byte

GetImportPkg get import package

func GetSourceImportPkg

func GetSourceImportPkg(services []*PbService) []byte

GetSourceImportPkg get source import package

Types

type Field

type Field struct {
	Name      string
	FieldType string
	Comment   string
}

Field request fields

func (Field) GoTypeZero

func (r Field) GoTypeZero() string

GoTypeZero default zero value for type

type PbService

type PbService struct {
	Name      string           // Greeter
	LowerName string           // greeter first character to lower
	ProtoName string           // proto file name greeter.proto
	Methods   []*ServiceMethod // service methods

	ImportPkgMap map[string]string // e.g. [userV1]:[userV1 "user/api/user/v1"]

	ProtoFileDir string // e.g. api/user/v1
	ProtoPkgName string // e.g. userV1
	ModuleName   string
}

PbService service fields

func GetServices

func GetServices(file *protogen.File, moduleName string) []*PbService

GetServices parse protobuf services

func (*PbService) RandNumber

func (s *PbService) RandNumber() int

RandNumber rand number 1~100

type ServiceMethod

type ServiceMethod struct {
	MethodName    string   // e.g. Create
	Request       string   // e.g. CreateRequest
	RequestFields []*Field // request fields
	Reply         string   // e.g. CreateReply
	ReplyFields   []*Field
	Comment       string // e.g. Create a record
	InvokeType    int    // 0:unary, 1: client-side streaming, 2: server-side streaming, 3: bidirectional streaming

	ServiceName      string // Greeter
	LowerServiceName string // greeter first character to lower

	RequestImportPkgName string // e.g. userV1
	ReplyImportPkgName   string // e.g. userV1
	ProtoPkgName         string // e.g. userV1
}

ServiceMethod method fields

func (*ServiceMethod) AddOne

func (t *ServiceMethod) AddOne(i int) int

AddOne counter

Jump to

Keyboard shortcuts

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