模板(Template)是數(shù)據(jù)驅(qū)動生成的基礎(chǔ),所有的代碼(rest api、rpc、model、docker、kube)生成都會依賴模板, 默認(rèn)情況下,模板生成器會選擇內(nèi)存中的模板進行生成,而對于有模板修改需求的開發(fā)者來講,則需要將模板進行落盤, 從而進行模板修改,在下次代碼生成時會加載指定路徑下的模板進行生成。
NAME:
goctl template - template operation
USAGE:
goctl template command [command options] [arguments...]
COMMANDS:
init initialize the all templates(force update)
clean clean the all cache templates
update update template of the target category to the latest
revert revert the target template to the latest
OPTIONS:
--help, -h show help
NAME:
goctl template init - initialize the all templates(force update)
USAGE:
goctl template init [command options] [arguments...]
OPTIONS:
--home value the goctl home path of the template
NAME:
goctl template clean - clean the all cache templates
USAGE:
goctl template clean [command options] [arguments...]
OPTIONS:
--home value the goctl home path of the template
NAME:
goctl template update - update template of the target category to the latest
USAGE:
goctl template update [command options] [arguments...]
OPTIONS:
--category value, -c value the category of template, enum [api,rpc,model,docker,kube]
--home value the goctl home path of the template
NAME:
goctl template revert - revert the target template to the latest
USAGE:
goctl template revert [command options] [arguments...]
OPTIONS:
--category value, -c value the category of template, enum [api,rpc,model,docker,kube]
--name value, -n value the target file name of template
--home value the goctl home path of the template
--home 指定模板存儲路徑
在代碼生成時可以通過--home來指定模板所在文件夾,目前已支持指定模板目錄的命令有:
默認(rèn)情況(在不指定--home)會從$HOME/.goctl目錄下讀取。
$ goctl template init --home $HOME/template
Templates are generated in /Users/anqiansong/template, edit on your risk!
$ goctl rpc new greet --home $HOME/template
Done
更多建議: