generator

package
v2.8.3 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(meta TMetadata, generators ...Generator) error

Types

type FieldName added in v2.4.7

type FieldName string

type Generator

type Generator interface {
	Generate(TMetadata) error
	DriverName() string
}

type IField

type IField interface {
	GetName() string
	GetGoType() string
}

type IObject

type IObject interface {
	Read(string, Schema) error
	FieldsMap() map[string]IField
	GetTable() string
}

type Metadata

type Metadata map[TemplateName]Schema

Metadata represents the metadata of the generated code. FIXME: concurrent map is not safe

func (Metadata) Each

func (m Metadata) Each(fn func(TemplateName, Schema) error) error

type MetadataArgs added in v2.8.0

type MetadataArgs struct {
	TMetadata
	Args map[string]string `json:"args"`
}

func DecodeToMetadataArgs added in v2.8.0

func DecodeToMetadataArgs(data []byte) (*MetadataArgs, error)

type PluginGenerator

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

func NewPluginGenerator

func NewPluginGenerator(bin string, opts ...PluginGeneratorOption) *PluginGenerator

func (*PluginGenerator) DriverName

func (g *PluginGenerator) DriverName() string

func (*PluginGenerator) Generate

func (g *PluginGenerator) Generate(t TMetadata) error

type PluginGeneratorOption added in v2.8.0

type PluginGeneratorOption func(*PluginGenerator)

func WithGeneratorArgs added in v2.8.0

func WithGeneratorArgs(args map[string]string) PluginGeneratorOption

type Schema

type Schema map[FieldName]any

func (Schema) GetDriver

func (om Schema) GetDriver() (string, error)

func (Schema) GetTable

func (om Schema) GetTable(dr string) (string, error)

type TMetadata

type TMetadata struct {
	Namespace     string
	Pkg           string
	Meta          Metadata
	Input         string
	Output        string
	DisableRawSQL bool
}

func (*TMetadata) Decode

func (tm *TMetadata) Decode(data []byte) error

func (TMetadata) Encode

func (tm TMetadata) Encode(args map[string]string) ([]byte, error)

func (TMetadata) IsDisableRawSQL

func (tm TMetadata) IsDisableRawSQL() bool

type TemplateName

type TemplateName string

Jump to

Keyboard shortcuts

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