Skip to main content

Introduction

goctl is pronounced as go control, not as go C-T-L. goctl means not to be controlled by the code, but to control it. Where go does not mean golang. When I designed goctl, I wanted to use her to free our hands πŸ‘ˆ

api generation​

NameFunctionExample
-ogenerate api filegoctl api -o user.api
newQuickly create an api servicegoctl api new user
formatapi formatting,vscodeUsing
-dirTarget Catalog
-iuWhether to automatically update goctl
-stdinWhether to read data from standard input
validateVerify that the api file is valid
-api Specify api file source
goctl api validate -api user.api
docgenerate doc markdown
-dir specify directory
goctl api doc -dir user
goGenerate golang api service
-dirSpecify the generated code directory
-apiSpecify api file source
-forceWhether to force an overwrite of an existing file
styleSpecify filename naming style,gozero: Lowercase,go_zero: Underline,GoZero: humps
javaGenerate code to access api service - java language
-dir specify code storage directory
-api specify api file source
tsGenerate code to access api service - ts language
-dirSpecify the code storage directory
-apiSpecify api file source
webapi
caller
unwrap
dartgenerate access to api service code-dart language
-dir specify code storage directory
-api specify api file source
ktGenerate code to access api services - kotlin language
-dirSpecify the code storage directory
-apiSpecify api file source
pkgSpecify package name
plugin-pluginExecutable files
-dirCode storage target folder
-apiapi source code file
-styleFile name naming formatting

rpc generation​

NameFunctionExample
newQuickly generate an rpc service
-idea identifies whether the command comes from the idea plugin, for idea plugin development use, terminal execution please ignore [optional parameter]
-style specifies the filename naming style, gozero:lowercase,go_zero:underscore,GoZero:hump
templatecreate a proto template file
-idea identifies whether the command comes from the idea plugin, for use in idea plugin development, ignore [optional parameter]
-out,o specifies the code storage directory
protoGenerate rpc services based on proto
-src,sSpecify the proto file source
-proto_path,ISpecify the proto import lookup directory, protoc native command, please refer to protoc -h to see the specific usage
-dir,dSpecify the code storage directory
-ideaIdentifies whether the command comes from the idea plugin, for idea plugin development use, terminal execution please ignore [optional parameter]
-styleSpecify filename naming style, gozero:lowercase,go_zero:underscore,GoZero:hump
modelModel layer code operation

mysql generates model code from mysql
  ddl specifies data source to generate model code for ddl file
    -src,s specifies the sql file source containing ddl, supports wildcard matching
    -dir,d specifies the code storage directory
    -style specifies the file name naming style, gozero: lowercase, go_zero: underscore, GoZero: camel
    -cache,c whether to generate code With redis cache logic, bool value
    -idea identifies whether the command comes from the idea plug-in and is used for idea plug-in development. Please ignore the terminal execution [optional parameter]<br/ >  datasourceSpecify data source to generate model code from database link
    -urlSpecify database link
    - table,t specifies the table name, supports wildcards
    -dir,d specifies the code storage directory
    -style specifies the file Name naming style, gozero: lowercase, go_zero: underscore, GoZero: camel case
    -cache,c whether the generated code has redis cache logic, bool value
    -idea identifies whether the command comes from the idea plug-in and is used for the development and use of the idea plug-in. Please ignore the [optional parameter] for terminal execution.

mongo generates model code from mongo< br/>  -type,t specifies the name of Go Type
  -cache,c whether the generated code has redis cache logic, bool value, default no
   -dir,d specifies the code generation directory
  -style refers to Specify the file name naming style, gozero: lowercase, go_zero: underscore, GoZero: camel case

model generation​

NameFunctionExample
mysqlGenerate model code from mysql
  ddl Specify data source to generate model code for ddl file
    -src,s Specify include The sql file source of ddl supports wildcard matching
    -dir,d specifies the code storage directory
    -style specifies the file name Naming style, gozero: lowercase, go_zero: underscore, GoZero: camel case
    -cache,c whether the generated code has redis cache logic, bool value
     -idea identifies whether the command comes from the idea plug-in and is used for the development and use of the idea plug-in, please ignore the terminal execution [optional parameter]
  datasource specifies that the data source is generated from the database link model code
    -url specifies the database link
    -table,t specifies the table name, supports wildcards
&emsp ;   -dir,d specifies the code storage directory
    -style specifies the file name naming style, gozero: lowercase, go_zero: underscore, GoZero: camel case
    -cache,c whether the generated code has redis cache logic, bool value
    -idea identifies whether the command comes from idea Plug-in, used for the development and use of idea plug-in, please ignore the terminal execution [optional parameter]
mongoGenerate model code from mongo
  -type,t Specify Go Type name
  -cache,c Whether the generated code has redis cache logic, bool value, default no
  -dir,d specifies the code generation directory
  -style specifies the file name naming style, gozero: lowercase, go_zero: underscore, GoZero :Hump

template operation​

NameFunctionExample
initSave api/rpc/model templategoctl template init
cleanclear cache templategoctl template clean
updateupdate template
-category,c specify the group name to be updated api/rpc/model
goctl template update -c api
revertrestore the specified template file
-category,c specify the name of the group to be updated api/rpc/model
-name,n specify the name of the template file

config configuration file generation​

NameFunctionExample
-path,pspecify the configuration file directorygoctl config -p user

docker generates Dockerfile​

NameFunctionExample
-gospecify main function file
-portSpecify the exposed port

upgrade goctl to update to the latest version​

kube Generate k8s deployment files​

deploy k8s deploymenet​

NameFunctionExample
-nameservice name
-namespacespecify k8s namespace
-imagespecify the image name
-secretSpecifies the k8s secret for getting the image
-requestCpuspecify the default cpu allocation
-requestMemspecify the default memory allocation
-limitCpuspecify the maximum cpu allocation
-limitMemspecify the maximum memory allocation
-odeployment.yaml output directory
-replicasspecify the number of replicas
-revisionsspecify the number of records to keep for the release
-portspecify the service port
-nodePortspecifies the port to which the service is exposed
-minReplicasspecify the minimum number of replicas
-maxReplicasspecify the maximum number of replicas