Files
gf/cmd/gf
hailaz a6485d53af fix(cmd/gf): Fixed an issue where formatting caused import errors in gf init (#4598)
This pull request refactors the way Go files are formatted after project
generation in the `geninit` package. The main change is replacing the
previous formatting utility with a new function that uses the standard
library's `go/format` package, ensuring that only code formatting is
applied and import paths are not inadvertently modified.

**Formatting improvements:**

* Replaced the use of `utils.GoFmt` with a new `formatGoFiles` function
that utilizes `go/format` for formatting Go files, avoiding unwanted
changes to local import paths.
(`cmd/gf/internal/cmd/geninit/geninit_generator.go`)
* Added the `formatGoFiles` function, which recursively formats all Go
files in a directory using `go/format` and logs any formatting errors.
(`cmd/gf/internal/cmd/geninit/geninit_generator.go`)
* Updated comments and references in the code to clarify that formatting
is now handled by `formatGoFiles` instead of `utils.GoFmt`.
(`cmd/gf/internal/cmd/geninit/geninit_ast.go`)

**Dependency changes:**

* Removed the import of the custom `utils` package and added the
standard `go/format` package to support the new formatting approach.
(`cmd/gf/internal/cmd/geninit/geninit_generator.go`)
2026-01-09 11:00:35 +08:00
..
2022-01-24 14:49:56 +08:00
2025-12-27 16:07:23 +08:00
2025-12-27 19:46:09 +08:00
2022-01-24 14:49:56 +08:00

English | 简体中文

gf

gf is a powerful CLI tool for building GoFrame application with convenience.

1. Install

1) PreCompiled Binary

You can also install gf tool using pre-built binaries: https://github.com/gogf/gf/releases

  1. Mac & Linux

     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
    

    If you're using zsh, you might need rename your alias by command alias gf=gf to resolve the conflicts between gf and git fetch.

  2. Windows Manually download, execute in command line it and then follow the instruction.

  3. Database support

    DB builtin support remarks
    mysql yes -
    mariadb yes -
    tidb yes -
    mssql yes -
    oracle yes -
    pgsql yes -
    sqlite yes -
    sqlitecgo no to support sqlite database on 32bit architecture systems, manually add package import to the source codes and do the building.
    clickhouse yes -
    dm no manually add package import to the source codes and do the building.

2) Manually Install

go install github.com/gogf/gf/cmd/gf/v2@latest # latest version
go install github.com/gogf/gf/cmd/gf/v2@v2.5.5 # certain version(should be >= v2.5.5)

2. Commands

$ gf -h
USAGE
    gf COMMAND [OPTION]

COMMAND
    up         upgrade GoFrame version/tool to latest one in current project
    env        show current Golang environment variables
    fix        auto fixing codes after upgrading to new GoFrame version
    run        running go codes with hot-compiled-like feature
    gen        automatically generate go files for dao/do/entity/pb/pbentity
    tpl        template parsing and building commands
    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
    doc        download https://pages.goframe.org/ to run locally

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.

3. FAQ

1). Command gf run returns pipe: too many open files

Please use ulimit -n 65535 to enlarge your system configuration for max open files for current terminal shell session, and then gf run.