core

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	Style                  string
	TableName              string
	TableComment           string
	ColumnName             string
	IsNullable             string
	DataType               string
	CharacterMaximumLength sql.NullInt64
	NumericPrecision       sql.NullInt64
	NumericScale           sql.NullInt64
	ColumnType             string
	ColumnComment          string
}

Column represents a database column.

type Enum

type Enum struct {
	Name    string
	Comment string
	Fields  []EnumField
}

Enum represents a protocol buffer enumerated type.

func (*Enum) AppendField

func (e *Enum) AppendField(ef EnumField) error

AppendField appends an EnumField to an Enum.

func (*Enum) String

func (e *Enum) String() string

String returns a string representation of an Enum.

type EnumCollection

type EnumCollection []*Enum

EnumCollection represents a sortable collection of enums.

func (EnumCollection) Len

func (ec EnumCollection) Len() int

func (EnumCollection) Less

func (ec EnumCollection) Less(i, j int) bool

func (EnumCollection) Swap

func (ec EnumCollection) Swap(i, j int)

type EnumField

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

EnumField represents a field in an enumerated type.

func NewEnumField

func NewEnumField(name string, tag int) EnumField

NewEnumField constructs an EnumField type.

func (EnumField) Name

func (ef EnumField) Name() string

Name returns the name of the enum field.

func (EnumField) String

func (ef EnumField) String() string

String returns a string representation of an Enum.

func (EnumField) Tag

func (ef EnumField) Tag() int

Tag returns the identifier tag of the enum field.

type Message

type Message struct {
	Name    string
	Comment string
	Fields  []MessageField
	Style   string
}

Message represents a protocol buffer message.

func (*Message) AppendField

func (m *Message) AppendField(mf MessageField) error

AppendField appends a message field to a message. If the tag of the message field is in use, an error will be returned.

func (Message) GenDefaultMessage

func (m Message) GenDefaultMessage(buf *bytes.Buffer)

GenDefaultMessage gen default message

func (Message) GenRpcAddReqRespMessage

func (m Message) GenRpcAddReqRespMessage(buf *bytes.Buffer)

GenRpcAddReqRespMessage gen add req message

func (Message) GenRpcDelReqMessage

func (m Message) GenRpcDelReqMessage(buf *bytes.Buffer)

GenRpcDelReqMessage gen add resp message

func (Message) GenRpcGetByIdReqMessage

func (m Message) GenRpcGetByIdReqMessage(buf *bytes.Buffer)

GenRpcGetByIdReqMessage gen add resp message

func (Message) GenRpcSearchReqMessage

func (m Message) GenRpcSearchReqMessage(buf *bytes.Buffer)

GenRpcSearchReqMessage gen add resp message

func (Message) GenRpcUpdateReqMessage

func (m Message) GenRpcUpdateReqMessage(buf *bytes.Buffer)

GenRpcUpdateReqMessage gen add resp message

func (Message) String

func (m Message) String() string

String returns a string representation of a Message.

type MessageCollection

type MessageCollection []*Message

MessageCollection represents a sortable collection of messages.

func (MessageCollection) Len

func (mc MessageCollection) Len() int

func (MessageCollection) Less

func (mc MessageCollection) Less(i, j int) bool

func (MessageCollection) Swap

func (mc MessageCollection) Swap(i, j int)

type MessageField

type MessageField struct {
	Typ  string
	Name string

	Comment string
	// contains filtered or unexported fields
}

MessageField represents the field of a message.

func NewMessageField

func NewMessageField(typ, name string, tag int, comment string) MessageField

NewMessageField creates a new message field.

func (MessageField) String

func (f MessageField) String() string

String returns a string representation of a message field.

func (MessageField) Tag

func (f MessageField) Tag() int

Tag returns the unique numbered tag of the message field.

type Schema

type Schema struct {
	Syntax      string
	ServiceName string
	GoPackage   string
	Package     string
	Imports     sort.StringSlice
	Messages    MessageCollection
	Enums       EnumCollection
}

Schema is a representation of a protobuf schema.

func GenerateSchema

func GenerateSchema(db *sql.DB, table string, ignoreTables, ignoreColumns []string, serviceName, goPkg, pkg, fieldStyle string) (*Schema, error)

GenerateSchema generates a protobuf schema from a database connection and a package name. A list of tables to ignore may also be supplied. The returned schema implements the `fmt.Stringer` interface, in order to generate a string representation of a protobuf schema. Do not rely on the structure of the Generated schema to provide any context about the protobuf types. The schema reflects the layout of a protobuf file and should be used to pipe the output of the `Schema.String()` to a file.

func (*Schema) AppendImport

func (s *Schema) AppendImport(imports string)

AppendImport adds an import to a schema if the specific import does not already exist in the schema.

func (*Schema) String

func (s *Schema) String() string

String returns a string representation of a Schema.

type Service

type Service struct{}

Service represents a protocol buffer service. TODO: Implement this in a schema.

type Table

type Table struct {
	TableName  string
	ColumnName string
}

Table represents a database table.

Jump to

Keyboard shortcuts

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