generator

package
v0.6.25 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "v0.1"

Variables

View Source
var GoModuleDirName = "github.com/go-tenchii/kratos"
View Source
var GoModuleImportPath = "github.com/go-tenchii/kratos"

Functions

func DeduceGenPkgName

func DeduceGenPkgName(genFiles []*descriptor.FileDescriptorProto) (string, error)

DeduceGenPkgName figures out the go package name to use for generated code. Will try to use the explicit go_package setting in a file (if set, must be consistent in all files). If no files have go_package set, then use the protobuf package name (must be consistent in all files)

func GetFieldRequired

GetFieldRequired is field required? eg. validate="required"

func GetFormOrJSONName

func GetFormOrJSONName(field *descriptor.FieldDescriptorProto) string

GetFormOrJSONName get name from form tag, then json tag then original name

func GetJSONFieldName

func GetJSONFieldName(field *descriptor.FieldDescriptorProto) string

GetJSONFieldName get name from gogoproto.jsontag else the original name

func IsMap

IsMap is protocol buffer map

func IsRepeated

func IsRepeated(field *descriptor.FieldDescriptorProto) bool

IsRepeated Is this field repeated?

func IsScalar

func IsScalar(field *descriptor.FieldDescriptorProto) bool

IsScalar Is this field a scalar numeric type?

func MakeIndentStr

func MakeIndentStr(i int) string

func ParseBMMethod

func ParseBMMethod(method *descriptor.MethodDescriptorProto) (*googleMethodOptionInfo, error)

ParseBMMethod parse BMMethodDescriptor form method descriptor proto

func ParseGeneratorParams

func ParseGeneratorParams(parameter string, result GeneratorParamsInterface) error

Types

type Base

type Base struct {
	Reg *typemap.Registry

	ImportPrefix string // String to prefix to imported package file names.

	// Package naming:
	GenPkgName  string // Name of the package that we're generating
	PackageName string // Name of the proto file package

	// List of files that were inputs to the generator. We need to hold this in
	// the struct so we can write a header for the file that lists its inputs.
	GenFiles []*descriptor.FileDescriptorProto

	// Output buffer that holds the bytes we want to write out for a single file.
	// Gets reset after working on a file.
	Output *bytes.Buffer

	// key: pkgName
	// value: importPath
	Deps map[string]string

	Params *ParamsBase
	// contains filtered or unexported fields
}

func (*Base) DeduceDeps

func (t *Base) DeduceDeps(file *descriptor.FileDescriptorProto) map[string]string

func (*Base) FormattedOutput

func (t *Base) FormattedOutput() string

func (*Base) GoPackageNameForProtoFile

func (t *Base) GoPackageNameForProtoFile(file *descriptor.FileDescriptorProto) string

func (*Base) GoTypeName

func (t *Base) GoTypeName(protoName string) string

Given a protobuf name for a Message, return the Go name we will use for that type, including its package prefix.

func (*Base) IsOwnPackage

func (t *Base) IsOwnPackage(protoName string) bool

IsOwnPackage ... protoName is fully qualified name of a type

func (*Base) P

func (t *Base) P(args ...string)

P forwards to g.gen.P, which prints output.

func (*Base) PrintComments

func (t *Base) PrintComments(comments typemap.DefinitionComments) bool

func (*Base) RegisterPackageName

func (t *Base) RegisterPackageName(name string) (alias string)

RegisterPackageName name is the go package name or proto pkg name return go pkg alias

func (*Base) Setup

func (t *Base) Setup(in *plugin.CodeGeneratorRequest, paramsOpt ...GeneratorParamsInterface)

func (*Base) SubstituteImportPath

func (t *Base) SubstituteImportPath(importPath string, importFile string) string

type BasicParam

type BasicParam struct{ ParamsBase }

func (*BasicParam) GetBase

func (b *BasicParam) GetBase() *ParamsBase

func (*BasicParam) SetParam

func (b *BasicParam) SetParam(key string, value string) error

type GeneratorParamsInterface

type GeneratorParamsInterface interface {
	GetBase() *ParamsBase
	SetParam(key string, value string) error
}

type HTTPInfo

type HTTPInfo struct {
	HttpMethod   string
	Path         string
	LegacyPath   string
	NewPath      string
	IsLegacyPath bool
	Title        string
	Description  string
	// is http path added in the google.api.http option ?
	HasExplicitHTTPPath bool
}

HTTPInfo http info for method

func GetHTTPInfo

GetHTTPInfo http info of method

type ParamsBase

type ParamsBase struct {
	ImportPrefix string            // String to prefix to imported package file names.
	ImportMap    map[string]string // Mapping from .proto file name to import path.
	//Tpl          bool              // generate service implementation template
	ExplicitHTTP bool // Only generate for method that add http option
}

Jump to

Keyboard shortcuts

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