GoFrame框架提供了功能强大的gf命令行开发辅助工具,是框架发展的一个重要组成部分,工具地址:
工具安装请参考仓库页面。工具安装成功后,可以通过gf或者gf -h查看所有支持的命令。复杂的命令可以通过gf COMMAND -h查看更详细的使用帮助信息,例如:gf gen -h。
工具职责
- 简化工程开发,提高开发效率
- 支持框架工程设计规范准确落地
注意事项
- 部分命令需要您先安装好
Golang基础的开发环境,环境安装具体请参考 环境安装 章节。 - 最新的
CLI工具版本会随着最新的框架版本走。
配置支持
工具的所有命令均同时支持命令行及配置文件配置参数,以提高易用性。当给定命令行参数时优先读取命令行参数,如果命令行参数不存在时,自动读取配置文件中对应的参数名称。
配置文件路径优先查找当前目录下的hack目录,其次按照框架默认的配置路径检索配置文件。框架默认的配置文件检索路径请参考章节:配置管理-文件配置
配置文件的格式示例:
# GoFrame CLI tool configuration.gfcli:gen:dao:- link: "mysql:root:12345678@tcp(127.0.0.1:3306)/test"tables: "user"removePrefix: "gf_"descriptionTag: truenoModelComment: truedocker:build: "-a amd64 -s linux -p temp"tagPrefixes:- ccr.ccs.tencentyun.com/xxx- hkccr.ccs.tencentyun.com/xxx- sgccr.ccs.tencentyun.com/xxx
注意以上配置示例仅供参考,具体配置项请参考具体命令帮助。
工具调试
当在工具的使用中遇到问题时,可以尝试打开工具的调试模式获得更详细的工具执行日志信息,打开工具调试模式可以通过gf.debug命令行选项开启,例如:
gf build main.go --gf.debug
由于gf工具也是使用GoFrame框架开发,因此调试信息的开启也是同框架方式一致,更详细的介绍请参考框架介绍文档:调试模式
命令总览
当前帮助文档以gf cli v2.0.0版本为例进行简单的介绍,详细的介绍信息请查看命令行帮助信息。本章内容信息可能会有滞后,最新的具体详细介绍请查看工具帮助信息。
$ gfUSAGEgf COMMAND [OPTION]COMMANDenv show current Golang environment variablesrun running go codes with hot-compiled-like featuregen automatically generate go files for dao/dto/entity/pb/pbentity...init create and initialize an empty GoFrame projectpack packing any file/directory to a resource file, or a go filebuild cross-building go project for lots of platformsdocker build docker image for current GoFrame projectinstall install gf binary to system (might need root/admin permission)version show version information of current binaryOPTION-y, --yes all yes for all command without prompt ask-v, --version show version information of current binary-d, --debug show internal detailed debugging information-h, --help more information about this commandADDITIONALUse "gf COMMAND -h" for details about a command.