准备工作

安装GF开发工具 gf-cli

相关文档:gf-cli 安装及使用

使用方式

项目地址:https://github.com/gogf/gf/tree/master/cmd/gf
我们已经预编译了常见系统平台的二进制(根据自己的系统环境选择):https://github.com/gogf/gf/releases
如果你的网络下载比较慢,可以使用加速下载:https://toolwa.com/github/

下载

预编译

  • Linux or MacOS 在终端执行:wget -O gf https://github.com/gogf/gf/releases/latest/download/gf_$(go env GOOS)_$(go env GOARCH) && chmod +x gf && ./gf install -y && rm ./gf
  • Windows:到https://github.com/gogf/gf/releases自行下载

    自行编译

  1. 下载源码https://github.com/gogf/gf
  2. 根据自己的需要修改数据库依赖,文件/cmd/gf/internal/cmd/cmd_gen_dao.go的import。sqlite 和oracle 的驱动需要安装cgo环境
  3. 进入到gf cli的源码目录/cmd/gf 编译

    安装到系统:

  • Linux or MacOS :下载时已包含安装步骤
  • Windows: 直接双击打开按步骤操作

    使用:

    安装后可在命令行的任意目录中使用gf 命令,执行gf -v测试是否安装成功
    部分系统需要管理员权限支持。
    如果是MacOS下使用zsh的小伙伴可能会遇到别名冲突问题,可以通过alias gf=gf来解决,运行一次之后gf工具会自动修改profile中的别名设置,用户重新登录(或者重开终端)就好了。

    使用示例

    安装

    $ ./gf_darwin_amd64 install 
    I found some installable paths for you(from $PATH):  
    Id | Writable | Installed | Path 
     0 |     true |      true | /usr/local/bin 
     1 |     true |     false | /Users/john/Workspace/Go/GOPATH/bin 
     2 |     true |     false | /Users/john/.gvm/bin 
     4 |     true |     false | /Users/john/.ft 
    please choose one installation destination [default 0]: 
    gf binary is successfully installed to: /usr/local/bin 
作者:管理员  创建时间:2023-01-06 15:03
最后编辑:管理员  更新时间:2024-03-20 12:01