Documentation ¶
Index ¶
- Constants
- Variables
- func DeduceGenPkgName(genFiles []*descriptor.FileDescriptorProto) (string, error)
- func GetFieldRequired(f *descriptor.FieldDescriptorProto, reg *typemap.Registry, ...) bool
- func GetFormOrJSONName(field *descriptor.FieldDescriptorProto) string
- func GetJSONFieldName(field *descriptor.FieldDescriptorProto) string
- func IsMap(field *descriptor.FieldDescriptorProto, reg *typemap.Registry) bool
- func IsRepeated(field *descriptor.FieldDescriptorProto) bool
- func IsScalar(field *descriptor.FieldDescriptorProto) bool
- func MakeIndentStr(i int) string
- func ParseBMMethod(method *descriptor.MethodDescriptorProto) (*googleMethodOptionInfo, error)
- func ParseGeneratorParams(parameter string, result GeneratorParamsInterface) error
- type Base
- func (t *Base) DeduceDeps(file *descriptor.FileDescriptorProto) map[string]string
- func (t *Base) FormattedOutput() string
- func (t *Base) GetHttpInfoCached(file *descriptor.FileDescriptorProto, ...) *HTTPInfo
- func (t *Base) GoPackageNameForProtoFile(file *descriptor.FileDescriptorProto) string
- func (t *Base) GoTypeName(protoName string) string
- func (t *Base) IsOwnPackage(protoName string) bool
- func (t *Base) P(args ...string)
- func (t *Base) PrintComments(comments typemap.DefinitionComments) bool
- func (t *Base) RegisterPackageName(name string) (alias string)
- func (t *Base) Setup(in *plugin.CodeGeneratorRequest, paramsOpt ...GeneratorParamsInterface)
- func (t *Base) ShouldGenForMethod(file *descriptor.FileDescriptorProto, ...) bool
- func (t *Base) SubstituteImportPath(importPath string, importFile string) string
- type BasicParam
- type GeneratorParamsInterface
- type HTTPInfo
- type ParamsBase
Constants ¶
const Version = "v0.1"
Variables ¶
var GoModuleDirName = "github.com/mapgoo-lab/atreus"
var GoModuleImportPath = "github.com/mapgoo-lab/atreus"
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 ¶
func GetFieldRequired( f *descriptor.FieldDescriptorProto, reg *typemap.Registry, md *typemap.MessageDefinition, ) bool
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 ¶
func IsMap(field *descriptor.FieldDescriptorProto, reg *typemap.Registry) bool
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 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 (*Base) GetHttpInfoCached ¶
func (t *Base) GetHttpInfoCached(file *descriptor.FileDescriptorProto, service *descriptor.ServiceDescriptorProto, method *descriptor.MethodDescriptorProto) *HTTPInfo
func (*Base) GoPackageNameForProtoFile ¶
func (t *Base) GoPackageNameForProtoFile(file *descriptor.FileDescriptorProto) string
func (*Base) GoTypeName ¶
Given a protobuf name for a Message, return the Go name we will use for that type, including its package prefix.
func (*Base) IsOwnPackage ¶
IsOwnPackage ... protoName is fully qualified name of a type
func (*Base) PrintComments ¶
func (t *Base) PrintComments(comments typemap.DefinitionComments) bool
func (*Base) RegisterPackageName ¶
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) ShouldGenForMethod ¶
func (t *Base) ShouldGenForMethod(file *descriptor.FileDescriptorProto, service *descriptor.ServiceDescriptorProto, method *descriptor.MethodDescriptorProto) bool
type BasicParam ¶
type BasicParam struct{ ParamsBase }
func (*BasicParam) GetBase ¶
func (b *BasicParam) GetBase() *ParamsBase
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 ¶
func GetHTTPInfo( file *descriptor.FileDescriptorProto, service *descriptor.ServiceDescriptorProto, method *descriptor.MethodDescriptorProto, reg *typemap.Registry) *HTTPInfo
GetHTTPInfo http info of method