toolx

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

PS 路径分隔符

View Source
const TplRepo = "https://blob.workits.cn/templates/"

TplRepo 远程仓库地址

Variables

View Source
var ErrExist = fmt.Errorf("exist") // 已存在
View Source
var ErrExit = fmt.Errorf("bye") // 退出

Functions

func AppendFile

func AppendFile(filePath, content string)

AppendFile 在文件末尾追加内容

func CamelCaseToUdnderscore

func CamelCaseToUdnderscore(s string) string

CamelCaseToUdnderscore 驼峰单词转下划线单词

func CopyTemplates

func CopyTemplates(projName string, force bool)

CopyTemplates 拷贝模版

func CreateConfig

func CreateConfig(projName string)

CreateConfig 创建配置

func DownloadTemplates

func DownloadTemplates(force bool)

DownloadTemplates 下载全局模版

func GenCode

func GenCode(projDir, moduleName, tableName, tableComment string)

GenCode 生成代码

func GenerateFile

func GenerateFile(projDir, typ string, data StructInfo) string

GenerateFile 生成文件

func IsFolderName

func IsFolderName(name string) bool

IsFolderName 是否是文件夹名称

func ModGlobalConfig

func ModGlobalConfig(projDir, comp string)

ModGlobalConfig 修改global.go

func NewComponent

func NewComponent(projDir, compName string)

NewComponent 添加组件

func NewModule

func NewModule(projDir, moduleName string)

NewModule 添加模块

func NewProject

func NewProject(projName, comp string)

func ParseTemplate

func ParseTemplate(src, dest string, params any)

ParseTemplate 解析模版

func ReadFileByLine

func ReadFileByLine(filePath string) []string

ReadFileByLine 读取文件

func RollbackGlobalConfig

func RollbackGlobalConfig(projDir, comp string)

RollbackGlobalConfig 回滚global.go

func RollbackGomod

func RollbackGomod(projDir, comp string)

RollbackGomod 回滚go.mod

func Run

func Run()

func UderscoreToLowerCamelCase

func UderscoreToLowerCamelCase(s string) string

UderscoreToLowerCamelCase 下划线单词转为小写驼峰单词

func UderscoreToUpperCamelCase

func UderscoreToUpperCamelCase(s string) string

UderscoreToUpperCamelCase 下划线单词转为大写驼峰单词

Types

type ColumnInfoEntity added in v0.1.0

type ColumnInfoEntity struct {
	zorm.EntityStruct

	Field   string `column:"Field"`
	Type    string `column:"Type"`
	Null    string `column:"Null"`
	Key     string `column:"Key"`
	Len     int    `column:"len"`
	Default string `column:"Default"`
	Comment string `column:"Comment"`
}

ColumnInfoEntity 字段信息实体

type DBConfig

type DBConfig struct {
	Driver  string `mapstructure:"driver"`
	Dialect string `mapstructure:"dialect"`
	Host    string `mapstructure:"host"`
	Port    int    `mapstructure:"port"`
	User    string `mapstructure:"user"`
	Pass    string `mapstructure:"pass"`
	Name    string `mapstructure:"name"`
}

DBConfig 数据库配置

func (DBConfig) DSN

func (db DBConfig) DSN() string

DSN 生成数据库连接字符串

type DBTool

type DBTool interface {
	TableToStructInfo(dbName, tableName string, isStandard bool) StructInfo
}

func NewDBTool

func NewDBTool(dbCfg dbx.Config) DBTool

type MySQLTool

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

func (*MySQLTool) TableToStructInfo added in v0.1.0

func (t *MySQLTool) TableToStructInfo(dbName, tableName string, isStandard bool) StructInfo

type PostgreSQLTool added in v0.1.0

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

func (*PostgreSQLTool) TableToStructInfo added in v0.1.0

func (t *PostgreSQLTool) TableToStructInfo(dbName, tableName string, isStandard bool) StructInfo

type SQLiteTableInfoEntity added in v0.1.0

type SQLiteTableInfoEntity struct {
	zorm.EntityStruct

	Name      string `column:"name"`
	Type      string `column:"type"`
	Notnull   int    `column:"notnull"`
	DfltValue string `column:"dflt_value"`
	PK        int    `column:"pk"`
}

type SQLiteTool added in v0.1.0

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

func (*SQLiteTool) TableToStructInfo added in v0.1.0

func (t *SQLiteTool) TableToStructInfo(dbName, tableName string, isStandard bool) StructInfo

type StructField

type StructField struct {
	FieldName    string
	ColumnName   string
	JsonName     string
	Type         string
	Required     bool
	Comment      string
	IsPrimaryKey bool
	Default      any
}

StructField 结构体字段信息

type StructInfo

type StructInfo struct {
	GoModule         string
	ProjModule       string
	ModName          string
	Name             string
	StructName       string
	TableName        string
	FileName         string
	PrimaryKeyColumn string
	PrimaryKeyField  string
	PrimaryKeyType   string
	PrimaryKeyName   string
	Fields           []StructField
	HasTime          bool
	HasDecimal       bool
	Comment          string
	IsStandard       bool
}

StructInfo 结构体信息

type TableInfoEntity added in v0.1.0

type TableInfoEntity struct {
	zorm.EntityStruct

	Name    string `column:"Name"`
	Comment string `column:"Comment"`

	Fields []*ColumnInfoEntity
}

TableInfoEntity 表信息实体

type VerInfo

type VerInfo struct {
	VBig   int
	VSmall int
	Ver    int
	TDir   string
	Meta   string
}

VerInfo 版本信息

type WkCfg

type WkCfg struct {
	GoModule string   `mapstructure:"go-module"`
	DB       DBConfig `mapstructure:"db"`
}

WkCfg 配置文件

Directories

Path Synopsis
cmd
wk

Jump to

Keyboard shortcuts

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