1 Star 0 Fork 25

泊舟 / gfstudy

forked from goflyfox / gfstudy 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
20.GoFrame工具链之其他命令.md 4.26 KB
一键复制 编辑 原始数据 按行查看 历史
zcool321@sina.com 提交于 2020-04-29 01:42 . add gf tool chain

GoFrame工具链之其他命令

获取包get

go.mod

module gfcli

go 1.13

获取包

$ gf get github.com/gogf/gf
go: github.com/gogf/gf upgrade => v1.12.2

go.mod

module gfcli

require github.com/gogf/gf v1.12.2 // indirect

go 1.13

打二进制包pack

$ gf pack -h
USAGE
    gf pack SRC DST

ARGUMENT
    SRC  source path for packing, which can be multiple source paths.
    DST  destination file path for packed file. if extension of the filename is ".go" and "-n" option is given,
         it enables packing SRC to go file, or else it packs SRC into a binary file.

OPTION
    -n, --name      package name for output go file
    -p, --prefix    prefix for each file packed into the resource file

EXAMPLES
    gf pack public data.bin
    gf pack public,template data.bin
    gf pack public,template boot/data.go -n=boot
    gf pack public,template,config resource/resource.go -n=resource
    gf pack public,template,config resource/resource.go -n=resource -p=/var/www/my-app
    gf pack /var/www/public resource/resource.go -n=resource
    
 $ gf pack config,public,template boot/data.go -n boot
done!

生成文件data.go,内容省略

package boot

import "github.com/gogf/gf/os/gres"

func init() {
	if err := gres.Add("1f8b0800000000000"); err != nil {
		panic(err)
	}
}

通过gres.Dump()打印

2020-04-28T17:06:23+00:00   0.00B config
2020-04-28T16:13:03+00:00   0.00B config/.gitkeep
2020-04-28T16:35:35+00:00 578.00B config/config.toml
2020-04-28T17:06:23+00:00   0.00B public
2020-04-28T16:13:03+00:00   0.00B public/html
2020-04-28T16:13:03+00:00   0.00B public/html/.gitkeep
2020-04-28T16:13:03+00:00   0.00B public/plugin
2020-04-28T16:13:03+00:00   0.00B public/plugin/.gitkeep
2020-04-28T16:13:03+00:00   0.00B public/resource
2020-04-28T16:13:03+00:00   0.00B public/resource/css
2020-04-28T16:13:03+00:00   0.00B public/resource/css/.gitkeep
2020-04-28T16:13:03+00:00   0.00B public/resource/image
2020-04-28T16:13:03+00:00   0.00B public/resource/image/.gitkeep
2020-04-28T16:13:03+00:00   0.00B public/resource/js
2020-04-28T16:13:03+00:00   0.00B public/resource/js/.gitkeep
2020-04-28T17:06:23+00:00   0.00B template
2020-04-28T16:13:03+00:00   0.00B template/.gitkeep

生成Dockerfile

$ gf docker -h
USAGE
    gf docker [FILE] [OPTION]

ARGUMENT
    FILE      file path for "gf build", it's "main.go" in default.
    OPTION    the same options as "docker build" except some options as follows defined

OPTION
    -p, --push  auto push the docker image to docker registry if "-t" option passed

EXAMPLES
    gf docker
    gf docker -t hub.docker.com/john/image:tag
    gf docker -p -t hub.docker.com/john/image:tag
    gf docker main.go
    gf docker main.go -t hub.docker.com/john/image:tag
    gf docker main.go -t hub.docker.com/john/image:tag
    gf docker main.go -p -t hub.docker.com/john/image:tag

DESCRIPTION
    The "docker" command builds the GF project to a docker images. It runs "docker build"
    command automatically, so you should have docker command first.
    There must be a Dockerfile in the root of the project.
    
$gf docker main.go -p -t 10.130.44.133/test/gfcli:v1.0.0
2020-04-29 00:57:54.378 start building...
2020-04-29 00:57:54.379 go build -o ./bin/linux_amd64/main main.go
2020-04-29 00:57:55.849 done!
2020-04-29 00:57:55.943 docker build .
2020-04-29 00:57:56.831 docker push 10.130.44.133/test/gfcli:v1.0.0

生成swagger文档

$ gf swagger -h
USAGE
    gf swagger [OPTION]

OPTION
    -s, --server  start a swagger server at specified address after swagger files
                  produced
    -o, --output  the output directory for storage parsed swagger files,
                  the default output directory is "./swagger"
    -/--pack      auto parses and packs swagger into boot/data-swagger.go.

EXAMPLES
    gf swagger
    gf swagger --pack
    gf swagger -s 8080
    gf swagger -s 127.0.0.1:8080
    gf swagger -o ./document/swagger


DESCRIPTION
    The "swagger" command parses the current project and produces swagger API description
    files, which can be used in swagger API server. If used with "-s/--server" option, it
    watches the changes of go files of current project and reproduces the swagger files,
    which is quite convenient for local API development.
1
https://gitee.com/ylmtest/gfstudy.git
git@gitee.com:ylmtest/gfstudy.git
ylmtest
gfstudy
gfstudy
master

搜索帮助