generate

package
v1.0.43 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: MIT Imports: 22 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     = modelInitDBFile
	ModelInitDBFileMark = modelInitDBFileMark
	AppConfigFileDBMark = appConfigFileMark2
	StartMark           = startMark
	EndMark             = endMark
)
View Source
var Replacers = map[string]replacer.Replacer{}

Replacers replacer name

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 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(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

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 SubServerCodeFields

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