v3

package
v2.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const Syntax = "proto3"

Variables

View Source
var (
	Double = Message{
		Name:     "double",
		IsScalar: true,
	}
	Float = Message{
		Name:     "float",
		IsScalar: true,
	}
	Int32 = Message{
		Name:     "int32",
		IsScalar: true,
	}
	Int64 = Message{
		Name:     "int64",
		IsScalar: true,
	}
	Uint32 = Message{
		Name:     "uint32",
		IsScalar: true,
	}
	Uint64 = Message{
		Name:     "uint64",
		IsScalar: true,
	}
	Bool = Message{
		Name:     "bool",
		IsScalar: true,
	}
	String = Message{
		Name:     "string",
		IsScalar: true,
	}
	Bytes = Message{
		Name:     "bytes",
		IsScalar: true,
	}
	Any = Message{
		Name:       "google.protobuf.Any",
		IsTopLevel: true,
		IsImported: true,
	}
	Empty = Message{
		Name:       "google.protobuf.Empty",
		IsTopLevel: true,
		IsImported: true,
	}
	Time = Message{
		Name:     "google.protobuf.Timestamp",
		IsScalar: true,
	}
)
View Source
var EnumStore = make(map[string]Enum)
View Source
var ImportStore = make(map[string]struct{})
View Source
var MessageNames []string
View Source
var MessageStore = make(map[string]Message)

Functions

This section is empty.

Types

type Enum

type Enum struct {
	Name   string
	Fields []EnumField
}

func (Enum) GetName

func (e Enum) GetName() string

func (Enum) Inner

func (e Enum) Inner() bool

func (Enum) String

func (e Enum) String() string

type EnumField

type EnumField struct {
	Name   string
	Number int
}

type Field

type Field struct {
	Name     string
	Type     ProtobufType
	Number   int
	Comments []string
	JsonName string
}

Field represents protobuf message field definition

type Message

type Message struct {
	Name       string
	Fields     []Field
	Comments   []string
	IsInner    bool
	IsScalar   bool
	IsMap      bool
	IsRepeated bool
	IsTopLevel bool
	// IsImported denotes the message will be imported from third-party, such as from google/protobuf
	IsImported bool
}

Message represents protobuf message definition

func (Message) GetName

func (m Message) GetName() string

func (Message) Inner

func (m Message) Inner() bool

func (Message) String

func (m Message) String() string

type ProtoGenerator

type ProtoGenerator struct {
	// contains filtered or unexported fields
}

func NewProtoGenerator

func NewProtoGenerator(options ...ProtoGeneratorOption) ProtoGenerator

func (ProtoGenerator) MessageOf

func (receiver ProtoGenerator) MessageOf(ft string) ProtobufType

func (ProtoGenerator) NewEnum

func (receiver ProtoGenerator) NewEnum(enumMeta astutils.EnumMeta) Enum

func (ProtoGenerator) NewMessage

func (receiver ProtoGenerator) NewMessage(structmeta astutils.StructMeta) Message

NewMessage returns message instance from astutils.StructMeta

func (ProtoGenerator) NewRpc

func (receiver ProtoGenerator) NewRpc(method astutils.MethodMeta) Rpc

func (ProtoGenerator) NewService

func (receiver ProtoGenerator) NewService(name, goPackage string) Service

type ProtoGeneratorOption

type ProtoGeneratorOption func(*ProtoGenerator)

func WithFieldNamingFunc

func WithFieldNamingFunc(fn func(string) string) ProtoGeneratorOption

type ProtobufType

type ProtobufType interface {
	GetName() string
	String() string
	Inner() bool
}

type Rpc

type Rpc struct {
	Name       string
	Request    Message
	Response   Message
	Comments   []string
	StreamType StreamType
}

type Service

type Service struct {
	Name      string
	Package   string
	GoPackage string
	Syntax    string
	// go-doudou version
	Version  string
	ProtoVer string
	Rpcs     []Rpc
	Messages []Message
	Enums    []Enum
	Comments []string
	Imports  []string
}

type StreamType

type StreamType int

Jump to

Keyboard shortcuts

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