generate

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: MIT Imports: 20 Imported by: 3

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 (
	// TplNameSponge name of the template
	TplNameSponge = "sponge"

	// 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     = modelInitDBFile
	ModelInitDBFileMark = modelInitDBFileMark
	AppConfigFileDBMark = appConfigFileMark2
	StartMark           = startMark
	EndMark             = endMark
)
View Source
var Replacers = map[string]replacer.Replacer{}

Replacers replacer name

Functions

func CacheCommand added in v1.4.2

func CacheCommand(parentName string) *cobra.Command

CacheCommand generate cache code

func ConfigCommand

func ConfigCommand() *cobra.Command

ConfigCommand convert yaml to struct command

func ConfigmapCommand added in v1.6.0

func ConfigmapCommand() *cobra.Command

ConfigmapCommand generate k8s configmap command

func ConvertSwagJSONCommand added in v1.4.2

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 added in v1.6.0

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

DeleteCodeMark delete code mark fragment

func GRPCAndHTTPPbCommand added in v1.8.0

func GRPCAndHTTPPbCommand() *cobra.Command

GRPCAndHTTPPbCommand generate grpc+http service code bash on protobuf file

func GRPCConnectionCommand added in v1.6.0

func GRPCConnectionCommand() *cobra.Command

GRPCConnectionCommand generate grpc connection code

func GetDBConfigurationCode added in v1.8.0

func GetDBConfigurationCode(dbDriver string) string

GetDBConfigurationCode get db config code

func GetInitDataBaseCode added in v1.6.0

func GetInitDataBaseCode(dbDriver string) string

GetInitDataBaseCode get init db code

func HTTPCommand

func HTTPCommand() *cobra.Command

HTTPCommand generate web service code

func HTTPPbCommand added in v1.2.0

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 added in v1.5.0

func HandlerPbCommand() *cobra.Command

HandlerPbCommand generate handler and protobuf code

func Init

func Init(name string, filepath string) error

Init initializing the template

func InitFS

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

InitFS initializing th FS templates

func ModelCommand

func ModelCommand(parentName string) *cobra.Command

ModelCommand generate model code

func ProtobufCommand added in v1.6.0

func ProtobufCommand() *cobra.Command

ProtobufCommand generate protobuf code

func RPCCommand added in v1.2.0

func RPCCommand() *cobra.Command

RPCCommand generate grpc service code

func RPCGwPbCommand added in v1.2.0

func RPCGwPbCommand() *cobra.Command

RPCGwPbCommand generate grpc gateway service code base on protobuf file

func RPCPbCommand added in v1.2.0

func RPCPbCommand() *cobra.Command

RPCPbCommand generate grpc service code bash on protobuf file

func ServiceAndHandlerCRUDCommand added in v1.8.0

func ServiceAndHandlerCRUDCommand() *cobra.Command

ServiceAndHandlerCRUDCommand generate both service and handler CRUD code

func ServiceCommand

func ServiceCommand() *cobra.Command

ServiceCommand generate service code

func SubServerCodeFields added in v1.7.0

func SubServerCodeFields(outDir string, 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 information

Jump to

Keyboard shortcuts

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