utils

package
v0.0.0-...-e2f8289 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2021 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDirectory

func CreateDirectory(dirName string) error

func CreateTestDatabase

func CreateTestDatabase() *memory.Database

func GetModelPackageName

func GetModelPackageName(outpath string) string

func GetModelPath

func GetModelPath(outpath string) string

func InitConfig

func InitConfig(opts ...ConfigOptionFunc)

func Keys

func Keys(t interface{}, exclude []string) []string

func NewConfigFromReader

func NewConfigFromReader(in io.Reader, cType string) *viper.Viper

func NewDB

func NewDB(vip *viper.Viper) *sql.DB

func ProviderConfig

func ProviderConfig(in io.Reader, cType string) *viper.Viper

func ProviderDB

func ProviderDB(vip *viper.Viper) *sql.DB

Types

type Callback

type Callback func()

type ColumnMeta

type ColumnMeta struct {
	FieldMapping
	Column *sql.ColumnType
}

func (*ColumnMeta) GenerateGo

func (self *ColumnMeta) GenerateGo(group *jen.Group)

func (*ColumnMeta) GetGoName

func (self *ColumnMeta) GetGoName() string

func (*ColumnMeta) GetJsonName

func (self *ColumnMeta) GetJsonName() string

func (*ColumnMeta) GetName

func (self *ColumnMeta) GetName() string

func (*ColumnMeta) GetSqlType

func (self *ColumnMeta) GetSqlType() string

func (*ColumnMeta) ParseAllTypes

func (self *ColumnMeta) ParseAllTypes(maps []*FieldMapping)

type ConfigOption

type ConfigOption struct {
	V    bool
	VV   bool
	VVV  bool
	VVVV bool
}

type ConfigOptionFunc

type ConfigOptionFunc func(opts *ConfigOption)

func WithV

func WithV(v bool) ConfigOptionFunc

func WithVV

func WithVV(vv bool) ConfigOptionFunc

func WithVVV

func WithVVV(vvv bool) ConfigOptionFunc

func WithVVVV

func WithVVVV(vvvv bool) ConfigOptionFunc

type FieldMapping

type FieldMapping struct {
	SqlType        string `json:"sql_type" deepcopier:"field:SqlType"`
	GoType         string `json:"go_type" deepcopier:"field:GoType"`
	JsonType       string `json:"json_type" deepcopier:"field:JsonType"`
	ProtobufType   string `json:"protobuf_type" deepcopier:"field:ProtobufType"`
	GureguType     string `json:"guregu_type" deepcopier:"field:GureguType"`
	GoNullableType string `json:"go_nullable_type" deepcopier:"field:GoNullableType"`
	SwaggerType    string `json:"swagger_type" deepcopier:"field:SwaggerType"`
	Size           int    `json:"size,omitempty"`
	Custom         string `json:"custom,omitempty"`
}

type MappingFile

type MappingFile struct {
	Mappings []*FieldMapping `json:"mappings"`
}

func NewMappingFromJSON

func NewMappingFromJSON(filename string) (*MappingFile, error)

type TableMeta

type TableMeta struct {
	Columns []*ColumnMeta

	Name          string
	Prefix        string
	PrimaryColumn *ColumnMeta
	OutputPath    string
	// contains filtered or unexported fields
}

func GetAllTableMeta

func GetAllTableMeta(db *sql.DB, vip *viper.Viper) ([]*TableMeta, error)

func (*TableMeta) BuildModel

func (self *TableMeta) BuildModel() *jen.File

func (*TableMeta) BuildName

func (self *TableMeta) BuildName(name string) *TableMeta

func (*TableMeta) BuildPrefix

func (self *TableMeta) BuildPrefix(prefix string) *TableMeta

func (*TableMeta) BuildRepo

func (self *TableMeta) BuildRepo() *jen.File

func (*TableMeta) GetAllColumnMeta

func (self *TableMeta) GetAllColumnMeta() ([]*ColumnMeta, error)

func (*TableMeta) GetFileName

func (self *TableMeta) GetFileName(modulePath string, genre string) string

func (*TableMeta) GetGoFileName

func (self *TableMeta) GetGoFileName() string

func (*TableMeta) GetModelName

func (self *TableMeta) GetModelName() string

func (*TableMeta) GetModelNameAsVariable

func (self *TableMeta) GetModelNameAsVariable() string

func (*TableMeta) GetModuleName

func (self *TableMeta) GetModuleName() string

func (*TableMeta) GetModulePath

func (self *TableMeta) GetModulePath(base string) string

func (*TableMeta) GetNameWithoutPrefix

func (self *TableMeta) GetNameWithoutPrefix() string

func (*TableMeta) SaveModel

func (self *TableMeta) SaveModel(modulePath string) error

func (*TableMeta) SaveRepo

func (self *TableMeta) SaveRepo(modulePath string) error

Jump to

Keyboard shortcuts

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