Documentation
¶
Overview ¶
Package generate is to generate code, including model, cache, dao, handler, http, service, grpc, grpc-gw, grpc-cli code.
Index ¶
- Constants
- Variables
- func CacheCommand(parentName string) *cobra.Command
- func ConfigCommand() *cobra.Command
- func ConfigmapCommand() *cobra.Command
- func DaoCommand(parentName string) *cobra.Command
- func DeleteCodeMark(r replacer.Replacer, filename string, startMark []byte, endMark []byte) []replacer.Field
- func GRPCAndHTTPCommand() *cobra.Command
- func GRPCAndHTTPPbCommand() *cobra.Command
- func GRPCConnectionCommand() *cobra.Command
- func GetDBConfigurationCode(dbDriver string) string
- func GetGoModFields(moduleName string) []replacer.Field
- func GetInitDataBaseCode(dbDriver string) string
- func HTTPCommand() *cobra.Command
- func HTTPPbCommand() *cobra.Command
- func HandleSwaggerJSONCommand() *cobra.Command
- func HandlerCommand() *cobra.Command
- func HandlerPbCommand() *cobra.Command
- func Init() error
- func InitFS(name string, filepath string, fs embed.FS)
- func ModelCommand(parentName string) *cobra.Command
- func ParseFuzzyProtobufFiles(protobufFile string) ([]string, error)
- func ProtobufCommand() *cobra.Command
- func RPCCommand() *cobra.Command
- func RPCGwPbCommand() *cobra.Command
- func RPCPbCommand() *cobra.Command
- func ServiceAndHandlerCRUDCommand() *cobra.Command
- func ServiceCommand() *cobra.Command
- func SetSelectFiles(dbDriver string, selectFiles map[string][]string) error
- func SubServerCodeFields(moduleName string, serverName string) []replacer.Field
- type KeyValue
- type OrderedMap
- type Template
- type Version
Constants ¶
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 ¶
var ( ModelInitDBFile = databaseInitDBFile ModelInitDBFileMark = databaseInitDBFileMark //AppConfigFileDBMark = appConfigFileMark2 StartMark = startMark EndMark = endMark )
var (
CurrentDbDriver = func(dbDriver string) string { return "// db driver is " + dbDriver }
)
var Replacers = map[string]replacer.Replacer{}
Replacers replacer name
var SpongeDir = getHomeDir() + gofile.GetPathDelimiter() + ".sponge"
SpongeDir sponge directory
Functions ¶
func CacheCommand ¶
CacheCommand generate cache code
func ConfigCommand ¶
ConfigCommand convert yaml to struct command
func ConfigmapCommand ¶
ConfigmapCommand generate k8s configmap command
func DeleteCodeMark ¶
func DeleteCodeMark(r replacer.Replacer, filename string, startMark []byte, endMark []byte) []replacer.Field
DeleteCodeMark delete code mark fragment
func GRPCAndHTTPCommand ¶ added in v1.13.0
GRPCAndHTTPCommand generate grpc+http servers code based on sql
func GRPCAndHTTPPbCommand ¶
GRPCAndHTTPPbCommand generate grpc+http servers code based on protobuf file
func GRPCConnectionCommand ¶
GRPCConnectionCommand generate grpc connection code
func GetDBConfigurationCode ¶
GetDBConfigurationCode get db config code
func GetGoModFields ¶
GetGoModFields get go mod fields
func GetInitDataBaseCode ¶
GetInitDataBaseCode get init db code
func HTTPPbCommand ¶
HTTPPbCommand generate web server code based on protobuf file
func HandleSwaggerJSONCommand ¶ added in v1.14.0
HandleSwaggerJSONCommand handle swagger json command
func HandlerPbCommand ¶
HandlerPbCommand generate handler and protobuf code
func ModelCommand ¶
ModelCommand generate model code
func ParseFuzzyProtobufFiles ¶
ParseFuzzyProtobufFiles parse fuzzy protobuf files
func RPCGwPbCommand ¶
RPCGwPbCommand generate grpc gateway server code base on protobuf file
func RPCPbCommand ¶
RPCPbCommand generate grpc server code based on protobuf file
func ServiceAndHandlerCRUDCommand ¶
ServiceAndHandlerCRUDCommand generate both service and handler CRUD code
func SetSelectFiles ¶
nolint
Types ¶
type KeyValue ¶ added in v1.14.0
type KeyValue struct { Key string Value interface{} }
KeyValue represents a key-value pair for ordered JSON marshaling
type OrderedMap ¶ added in v1.14.0
type OrderedMap []KeyValue
OrderedMap is a slice of KeyValue pairs, representing an ordered JSON object.
func (OrderedMap) MarshalJSON ¶ added in v1.14.0
func (om OrderedMap) MarshalJSON() ([]byte, error)
MarshalJSON custom marshals OrderedMap to JSON, preserving key order.