kratos: Index | Files

package generator

import ""


Package Files

command_line.go generator.go helper.go http.go


const Version = "v0.1"


var GoModuleDirName = ""
var GoModuleImportPath = ""

func DeduceGenPkgName Uses

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 Uses

func GetFieldRequired(
    f *descriptor.FieldDescriptorProto,
    reg *typemap.Registry,
    md *typemap.MessageDefinition,
) bool

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

func GetFormOrJSONName Uses

func GetFormOrJSONName(field *descriptor.FieldDescriptorProto) string

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

func GetJSONFieldName Uses

func GetJSONFieldName(field *descriptor.FieldDescriptorProto) string

GetJSONFieldName get name from gogoproto.jsontag else the original name

func IsMap Uses

func IsMap(field *descriptor.FieldDescriptorProto, reg *typemap.Registry) bool

IsMap is protocol buffer map

func IsRepeated Uses

func IsRepeated(field *descriptor.FieldDescriptorProto) bool

IsRepeated Is this field repeated?

func IsScalar Uses

func IsScalar(field *descriptor.FieldDescriptorProto) bool

IsScalar Is this field a scalar numeric type?

func MakeIndentStr Uses

func MakeIndentStr(i int) string

func ParseBMMethod Uses

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

ParseBMMethod parse BMMethodDescriptor form method descriptor proto

func ParseGeneratorParams Uses

func ParseGeneratorParams(parameter string, result GeneratorParamsInterface) error

type Base Uses

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 Uses

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

func (*Base) FormattedOutput Uses

func (t *Base) FormattedOutput() string

func (*Base) GetHttpInfoCached Uses

func (t *Base) GetHttpInfoCached(file *descriptor.FileDescriptorProto,
    service *descriptor.ServiceDescriptorProto,
    method *descriptor.MethodDescriptorProto) *HTTPInfo

func (*Base) GoPackageNameForProtoFile Uses

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

func (*Base) GoTypeName Uses

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 Uses

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

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

func (*Base) P Uses

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

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

func (*Base) PrintComments Uses

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

func (*Base) RegisterPackageName Uses

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 Uses

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

func (*Base) ShouldGenForMethod Uses

func (t *Base) ShouldGenForMethod(file *descriptor.FileDescriptorProto,
    service *descriptor.ServiceDescriptorProto,
    method *descriptor.MethodDescriptorProto) bool

func (*Base) SubstituteImportPath Uses

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

type BasicParam Uses

type BasicParam struct{ ParamsBase }

func (*BasicParam) GetBase Uses

func (b *BasicParam) GetBase() *ParamsBase

func (*BasicParam) SetParam Uses

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

type GeneratorParamsInterface Uses

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

type HTTPInfo Uses

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 Uses

func GetHTTPInfo(
    file *descriptor.FileDescriptorProto,
    service *descriptor.ServiceDescriptorProto,
    method *descriptor.MethodDescriptorProto,
    reg *typemap.Registry) *HTTPInfo

GetHTTPInfo http info of method

type ParamsBase Uses

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

Package generator imports 22 packages (graph) and is imported by 2 packages. Updated 2020-08-05. Refresh now. Tools for package owners.