generate

package
v1.1.46 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2025 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package generate is to generate code, including model, cache, dao, handler, http, service, grpc, grpc-gw, grpc-cli code.

Index

Constants

View Source
const (

	// TplNameSunshine name of the template
	TplNameSunshine = "sunshine"

	// DBDriverMysql mysql driver
	DBDriverMysql = "mysql"
	// DBDriverPostgresql postgresql driver
	DBDriverPostgresql = "postgresql"
	// DBDriverTidb tidb driver
	DBDriverTidb = "tidb"
	// DBDriverSqlite sqlite driver
	DBDriverSqlite = "sqlite"
	// DBDriverMongodb mongodb driver
	DBDriverMongodb = "mongodb"
)

Variables

View Source
var (
	ModelInitDBFile     = databaseInitDBFile
	ModelInitDBFileMark = databaseInitDBFileMark
	//AppConfigFileDBMark = appConfigFileMark2
	StartMark = startMark
	EndMark   = endMark
)
View Source
var (
	CurrentDbDriver = func(dbDriver string) string { return "// db driver is " + dbDriver }
)
View Source
var Replacers = map[string]replacer.Replacer{}

Replacers 存储替换器的映射

View Source
var SunshineDir = getHomeDir() + gofile.GetPathDelimiter() + ".sunshine"

SunshineDir .sunshine 目录的路径

Functions

func CacheCommand

func CacheCommand(parentName string) *cobra.Command

CacheCommand generate cache code

func ConfigCommand

func ConfigCommand() *cobra.Command

ConfigCommand convert yaml to struct command

func ConfigmapCommand

func ConfigmapCommand() *cobra.Command

ConfigmapCommand generate k8s configmap command

func ConvertSwagJSONCommand

func ConvertSwagJSONCommand(parentName string) *cobra.Command

ConvertSwagJSONCommand convert 64-bit fields type string to integer

func DaoCommand

func DaoCommand(parentName string) *cobra.Command

DaoCommand generate dao code

func DeleteCodeMark

func DeleteCodeMark(r replacer.Replacer, filename string, startMark []byte, endMark []byte) []replacer.Field

DeleteCodeMark delete code mark fragment

func GRPCAndHTTPPbCommand

func GRPCAndHTTPPbCommand() *cobra.Command

GRPCAndHTTPPbCommand generate grpc+http service code bash on protobuf file

func GRPCConnectionCommand

func GRPCConnectionCommand() *cobra.Command

GRPCConnectionCommand generate grpc connection code

func GetDBConfigurationCode

func GetDBConfigurationCode(dbDriver string) string

GetDBConfigurationCode get db config code

func GetGoModFields added in v1.1.18

func GetGoModFields(moduleName string) []replacer.Field

GetGoModFields get go mod fields

func GetInitDataBaseCode

func GetInitDataBaseCode(dbDriver string) string

GetInitDataBaseCode get init db code

func HTTPCommand

func HTTPCommand() *cobra.Command

HTTPCommand generate web service code

func HTTPPbCommand

func HTTPPbCommand() *cobra.Command

HTTPPbCommand generate web service code based on protobuf file

func HandlerCommand

func HandlerCommand() *cobra.Command

HandlerCommand generate handler code

func HandlerPbCommand

func HandlerPbCommand() *cobra.Command

HandlerPbCommand generate handler and protobuf code

func Init

func Init() error

Init 初始化模板

func InitFS

func InitFS(name string, filepath string, fs embed.FS)

InitFS 初始化嵌入文件系统的模板

func ModelCommand

func ModelCommand(parentName string) *cobra.Command

ModelCommand 生成模型代码的命令 该命令根据 SQL 生成模型代码。

func ParseFuzzyProtobufFiles added in v1.1.23

func ParseFuzzyProtobufFiles(protobufFile string) ([]string, error)

ParseFuzzyProtobufFiles parse fuzzy protobuf files

func ProtobufCommand

func ProtobufCommand() *cobra.Command

ProtobufCommand generate protobuf code

func RPCCommand

func RPCCommand() *cobra.Command

RPCCommand generate grpc service code

func RPCGwPbCommand

func RPCGwPbCommand() *cobra.Command

RPCGwPbCommand generate grpc gateway service code base on protobuf file

func RPCPbCommand

func RPCPbCommand() *cobra.Command

RPCPbCommand generate grpc service code bash on protobuf file

func ServiceAndHandlerCRUDCommand

func ServiceAndHandlerCRUDCommand() *cobra.Command

ServiceAndHandlerCRUDCommand generate both service and handler CRUD code

func ServiceCommand

func ServiceCommand() *cobra.Command

ServiceCommand generate service code

func SetSelectFiles added in v1.1.23

func SetSelectFiles(dbDriver string, selectFiles map[string][]string) error

nolint

func SubServerCodeFields

func SubServerCodeFields(moduleName string, serverName string) []replacer.Field

SubServerCodeFields sub server code fields

Types

type Template

type Template struct {
	Name     string   // 模板名称
	FS       embed.FS // 嵌入的文件系统
	FilePath string   // 文件路径
}

Template 模板信息结构体

type Version added in v1.1.23

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

Jump to

Keyboard shortcuts

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