protobuf

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPackageNameAndPath

func GetPackageNameAndPath(plugin *protogen.Plugin) (string, string, string, error)

GetPackageNameAndPath try to retrieve the golang module name from the list of .proto files.

Types

type Enum

type Enum struct {
	Name   string
	Prefix string
	Values []*EnumEntry
	Proto  *descriptor.EnumDescriptorProto
}

func ParseEnumsFromFile

func ParseEnumsFromFile(file *protogen.File) []*Enum

func (*Enum) String

func (e *Enum) String() string

type EnumEntry

type EnumEntry struct {
	ProtoName string
	Proto     *descriptor.EnumValueDescriptorProto
}

func (*EnumEntry) String

func (e *EnumEntry) String() string

type Field

type Field struct {
	Name     string
	JsonName string
	GoName   string
	TypeName string
	Type     descriptor.FieldDescriptorProto_Type
	Schema   *protogen.Field
	Proto    *descriptor.FieldDescriptorProto
	// contains filtered or unexported fields
}

func (*Field) EnumPackage

func (f *Field) EnumPackage() (string, string, bool)

func (*Field) GetWrapperType

func (f *Field) GetWrapperType() string

func (*Field) IsArray

func (f *Field) IsArray() bool

IsArray indicates if the Field is declared as repeated or not.

func (*Field) IsEnum

func (f *Field) IsEnum() bool

func (*Field) IsMap

func (f *Field) IsMap() bool

func (*Field) IsMessage

func (f *Field) IsMessage() bool

func (*Field) IsMessageFromPackage

func (f *Field) IsMessageFromPackage() bool

IsMessageFromPackage checks if the Field is a message, and it belongs to the current package or not.

func (*Field) IsMessageTypeOf

func (f *Field) IsMessageTypeOf(typeOf string) bool

IsMessageTypeOf checks if the Field is of a specific message type.

func (*Field) IsOptional

func (f *Field) IsOptional() bool

IsOptional indicates if the Field is declared as optional or not.

func (*Field) IsProtoAny

func (f *Field) IsProtoAny() bool

IsProtoAny checks if the Field is of 'google.protobuf.Any' type.

func (*Field) IsProtoStruct

func (f *Field) IsProtoStruct() bool

IsProtoStruct checks if the Field is of 'google.protobuf.Struct' type.

func (*Field) IsProtoValue

func (f *Field) IsProtoValue() bool

IsProtoValue checks if the Field is of 'google.protobuf.Value' type.

func (*Field) IsProtobufWrapper

func (f *Field) IsProtobufWrapper() bool

func (*Field) IsTimestamp

func (f *Field) IsTimestamp() bool

IsTimestamp checks if the Field is of 'google.protobuf.Timestamp' type.

func (*Field) MapKeyType

func (f *Field) MapKeyType() string

func (*Field) MapValueType

func (f *Field) MapValueType() string

func (*Field) MapValueTypeKind

func (f *Field) MapValueTypeKind() protoreflect.Kind

func (*Field) MapValueTypeName

func (f *Field) MapValueTypeName() string

func (*Field) MessagePackage

func (f *Field) MessagePackage() (string, string, bool)

MessagePackage returns the message package name and a flag indicating if it belongs to the current package or not.

func (*Field) ModuleName

func (f *Field) ModuleName() string

func (*Field) String

func (f *Field) String() string

type Message

type Message struct {
	Name       string
	Fields     []*Field
	Schema     *protogen.Message
	Proto      *descriptor.DescriptorProto
	ModuleName string
}

func ParseMessagesFromFile

func ParseMessagesFromFile(file *protogen.File, moduleName string) []*Message

func (*Message) String

func (m *Message) String() string

type Method

type Method struct {
	Name         string
	RequestType  *Name
	ResponseType *Name
	HTTPMethod   string
	Endpoint     string
	Proto        *descriptor.MethodDescriptorProto
}

func (*Method) HasHTTPBody

func (m *Method) HasHTTPBody() bool

func (*Method) String

func (m *Method) String() string

type Name

type Name struct {
	Name      string
	ProtoName string
	Package   string
}

func (*Name) String

func (n *Name) String() string

type ParseOptions

type ParseOptions struct {
	Plugin *protogen.Plugin
}

type Protobuf

type Protobuf struct {
	ModuleName   string
	PackageName  string
	FullPath     string
	Service      *Service
	Messages     []*Message
	Enums        []*Enum
	PackageFiles map[string]*protogen.File
	Files        map[string]*protogen.File
}

func Parse

func Parse(options ParseOptions) (*Protobuf, error)

func (*Protobuf) String

func (p *Protobuf) String() string

type Service

type Service struct {
	Name    string
	Methods []*Method
	Proto   *descriptor.ServiceDescriptorProto
}

func (*Service) IsHTTP

func (s *Service) IsHTTP() bool

func (*Service) String

func (s *Service) String() string

Jump to

Keyboard shortcuts

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