GoFrame 開發(fā)工具-簡介

2022-03-29 15:35 更新

?GoFrame?框架提供了功能強(qiáng)大的?gf?命令行開發(fā)輔助工具,是框架發(fā)展的一個重要組成部分,工具地址:

工具安裝請參考倉庫頁面。工具安裝成功后,可以通過?gf?或者?gf -h?查看所有支持的命令。復(fù)雜的命令可以通過?gf COMMAND -h?查看更詳細(xì)的使用幫助信息,例如:?gf gen -h?。

工具職責(zé)

  1. 簡化工程開發(fā),提高開發(fā)效率
  2. 支持框架工程設(shè)計規(guī)范準(zhǔn)確落地

注意事項

  1. 部分命令需要您先安裝好Golang基礎(chǔ)的開發(fā)環(huán)境。
  2. 最新的?CLI?工具版本會隨著最新的框架版本走。

配置支持

工具的所有命令均同時支持命令行及配置文件配置參數(shù),以提高易用性。配置文件路徑優(yōu)先查找當(dāng)前目錄下的?hack?目錄,其次按照框架默認(rèn)的配置路徑檢索配置文件。

以?gf gen dao?命令的配置文件的格式示例:

# GoFrame CLI tool configuration.
gfcli:
  gen:
    dao:
    - link:            "mysql:root:12345678@tcp(127.0.0.1:3306)/test"
      tables:          "user"
      removePrefix:    "gf_"
      descriptionTag:  true
      noModelComment:  true

注意以上配置示例僅供參考,具體配置項請參考具體命令幫助。

工具調(diào)試

當(dāng)在工具的使用中遇到問題時,可以嘗試打開工具的調(diào)試模式獲得更詳細(xì)的工具執(zhí)行日志信息,打開工具調(diào)試模式可以通過?gf.debug?命令行選項開啟,例如:

gf build main.go --gf.debug

由于?gf?工具也是使用?GoFrame?框架開發(fā),因此調(diào)試信息的開啟也是同框架方式一致。

命令總覽

當(dāng)前幫助文檔以?gf cli v2.0.0?版本為例進(jìn)行簡單的介紹,詳細(xì)的介紹信息請查看命令行幫助信息。本章內(nèi)容信息可能會有滯后,最新的具體詳細(xì)介紹請查看工具幫助信息。

$ gf
USAGE
   gf COMMAND [OPTION]

COMMAND
   env        show current Golang environment variables
   run        running go codes with hot-compiled-like feature
   gen        automatically generate go files for dao/dto/entity/pb/pbentity...
   init       create and initialize an empty GoFrame project
   pack       packing any file/directory to a resource file, or a go file
   build      cross-building go project for lots of platforms
   docker     build docker image for current GoFrame project
   install    install gf binary to system (might need root/admin permission)
   version    show version information of current binary

OPTION
   -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 command

ADDITIONAL
    Use "gf COMMAND -h" for details about a command.  


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號