GithubHelp home page GithubHelp logo

gogf / gf-cli Goto Github PK

View Code? Open in Web Editor NEW
251.0 15.0 105.0 7.56 MB

GoFrame Command Line Interface, which is your helpmate for building GoFrame application with convenience.

Home Page: https://goframe.org

License: MIT License

Go 99.53% Makefile 0.47%
cli gf goframe crossbuild autobuild swagger generator model packer proto

gf-cli's People

Contributors

astraw99 avatar gqcn avatar hailaz avatar housemecn avatar jianchenma avatar notnear avatar playhi avatar qinyuguang778 avatar stardemo avatar syhily avatar zcool321 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gf-cli's Issues

gf run 无法热编译项目

gf run main.go 只能热编译 main.go 文件的修改,修改main.go 导入的包文件 如何才能热编译呢?

cannot find the dao Ctx function

when i use gf gen dao -r weixin_, it generate a dao function in the dao/internal/xxx.go, but it lacks of the Ctx function.
As the follow msg show,
image
gf frame version:v1.14.5
gf-cli version:v1.14.5

gen 命令行带-g xcx生成模型报错

命令行

gf gen model ./app/model/xcx -p xcx_ -g xcx -t xcx_cat -l "mysql:root:!@#toor1025@tcp(101.132.141.31:3306)/csxcx"

config.toml 配置信息

# 数据库连接
[database]
    [[database.default]]
        link = "mysql:root:!@#toor1025@tcp(101.132.141.31:3306)/ytkhelp"
    [[database.xcx]]
        link = "mysql:root:!@#toor1025@tcp(101.132.141.31:3306)/csxcx" #测试

报错结果
image

swagger 无法生成swagger.json

gf run main.go --swagger -mod=vendor
2020-02-16 19:24:33.577 build: main.go
2020-02-16 19:24:33.640 producing swagger files...
2020-02-16 19:24:33.779 Incorrect Usage: flag provided but not defined: -o

NAME:
swag init - Create docs.go

USAGE:
swag init [command options] [arguments...]

OPTIONS:
--generalInfo value Go file path in which 'swagger general API Info' is written (default: "main.go")
--dir value Directory you want to parse (default: "./")
--propertyStrategy value Property Naming Strategy like snakecase,camelcase,pascalcase (default: "camelcase") --output value Output directory for all the generated files(swagger.json, swagger.yaml and doc.go) (default: "./docs")
--parseVendor Parse go files in 'vendor' folder, disabled by default (default: false)
--parseDependency Parse go files in outside dependency folder, disabled by default (default: false)
--markdownFiles value Parse folder containing markdown files to use as description, disabled by default
--generatedTime Generate timestamp at the top of docs.go, true by default (default: false)
--help, -h show help (default: false)

2020/02/16 19:24:33 flag provided but not defined: -o

域名路由使用方法请教

作者大大您好,我是一位PHP开发者主要使用thinkphp,目前转向go语言使用gf框架开发
自我感觉,gf框架对PHP开发者非常友好,通俗易懂。
目前遇到有一个需求,才疏学浅难以实现,希望作者大大不吝赐教
需求:根据不同的域名前缀访问不同的模块
详情:在域名泛解析的前提下

  1. admin.domain.com 访问 后台
  2. wap.domain.com 访问移动端
  3. api.domain.com 访问api接口
  4. 除了admin,wap,api外的域名前缀包括无前缀都访问 wwwPC端

目前根据文档提供的域名路由实现了前面三个域名与对应的路由绑定
最后一个无法实现

谢谢作者大大,作者大大辛苦了

Mac下安装gf-cli失败, zsh: exec format error: ./gf

renxuedong@yq  ~  wget https://goframe.org/cli/linux_amd64/gf && chmod +x gf && ./gf install
--2020-08-19 19:00:12-- https://goframe.org/cli/linux_amd64/gf
正在解析主机 goframe.org (goframe.org)... 47.244.3.49
正在连接 goframe.org (goframe.org)|47.244.3.49|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Found
位置:https://gfcdn.johng.cn/cli/linux_amd64/gf?534618d654b6f921ff166a0ccdc2f94f [跟随至新的 URL]
--2020-08-19 19:00:14-- https://gfcdn.johng.cn/cli/linux_amd64/gf?534618d654b6f921ff166a0ccdc2f94f
正在解析主机 gfcdn.johng.cn (gfcdn.johng.cn)... 36.99.196.217
正在连接 gfcdn.johng.cn (gfcdn.johng.cn)|36.99.196.217|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:21877703 (21M) [application/octet-stream]
正在保存至: “gf”

gf 100%[=====================================================================================================>] 20.86M 1.37MB/s 用时 16s

2020-08-19 19:00:31 (1.31 MB/s) - 已保存 “gf” [21877703/21877703])

zsh: exec format error: ./gf

生成model代码增强

1、设置忽略表的前缀,列如习惯表开头用“t_”, 如t_user, t_file;
习惯函数开头用"f_", 存储过程开头“pr_”
但生成model需要忽略掉前缀
2、生成model希望能把表字段注释和表注释带过来,方便阅读代码

thanks,John

生成的Entity类型有BUG

type Entity struct {
    Id        int    `orm:"id,primary" json:"id"`         // 主键          
    UserName  string `orm:"user_name"  json:"user_name"`  // 用户名        
    Password  string `orm:"password"   json:"password"`   // 密码          
    CreatedAt int    `orm:"created_at" json:"created_at"` // 创建时间      
    UpdatedAt int    `orm:"updated_at" json:"updated_at"` // 更新时间      
    Mobile    string `orm:"mobile"     json:"mobile"`     // 手机号        
    LoginAt   int    `orm:"login_at"   json:"login_at"`   // 最后登录时间  
    LoginType int    `orm:"login_type" json:"login_type"` // 登录方式      
}

上面的代码中,我的id是bigint unsigned,应该生成uint64这个类型的吧?
梳理代码发现是gen_model.go这个文件中的问题

func generateStructField(field *gdb.TableField) []string {
	var typeName, ormTag, jsonTag, comment string
	t, _ := gregex.ReplaceString(`\(.+\)`, "", field.Type)
	t = strings.ToLower(t)
	switch t {
	case "binary", "varbinary", "blob", "tinyblob", "mediumblob", "longblob":
		typeName = "[]byte"

这里的有问题,输出t的值是bigint unsigned这种,不是bigint,需要分割一下

MSSQL gen model nvarchar 字段类型有问题

SELECT NAME,XTYPE FROM systypes
WHERE NAME IN ('nvarchar', 'sysname')
ORDER BY XTYPE

以上sql查询,可以看到
image
两者 XTYPE 都是231
这就导致
github.com\gogf\[email protected]\database\gdb\gdb_driver_mssql.go
image
这里的语句

SELECT c.name as FIELD, CASE t.name
				WHEN 'numeric' THEN t.name + '(' + convert(varchar(20),c.xprec) + ',' + convert(varchar(20),c.xscale) + ')'
				WHEN 'char' THEN t.name + '(' + convert(varchar(20),c.length)+ ')'
				WHEN 'varchar' THEN t.name + '(' + convert(varchar(20),c.length)+ ')'
				ELSE t.name + '(' + convert(varchar(20),c.length)+ ')' END as TYPE
			FROM systypes t,syscolumns c WHERE t.xtype=c.xtype -- 一个字段名可能对应多个类型
			AND c.id = (SELECT id FROM sysobjects WHERE name='表名')
			ORDER BY c.colid

然后后面就会出现index错位的问题

测试数据库:
sql2017
sql2008

增加upx压缩选项

郭大神,这个cli工具好用,希望增加一个upx压缩选项,例如,配置了upx.exe的路径时,自动调用upx压缩

bug:gf build main.go --pack

GoFrame CLI Tool v1.14.5, https://goframe.org
Build Detail:
  Go Version:  go1.15.5
  GF Version:  v1.14.6
  Git Commit:  ffc56c7e5925cd3001302ab56ef82ceb1171c01b
  Build Time:  2020-12-25 10:47:04

执行命令gf build main.go --pack
生成目录文件packed/data.go
package为. 而非packed
image
另外问下--pack能否增加参数?

GF-CLI 生成 MSSQL的表模型

GF-CLI 生成 MSSQL的表模型有个小BUG,生成的字段名称是先strings.ToLower之后再gstr.CamelCase的,造成MSSQL生成的*_entity.go文件结构体字段名称不友好,如数据表中字段为MailID,生成的值就为Mailid,我找了一下发现是database/gdb/gdb_driver_mssql.go这个文件的222行处,做的转小写操作,这里需要修改一下。

mssql 在遇到 NVARCHAR 类型时,会出现数组越界

gf gen model -t merchant

2020-08-31 16:22:59.041 [DEBU] [ 13 ms] SELECT c.name as FIELD, CASE t.name WHEN 'numeric' THEN t.name + '(' + convert(varchar(20),c.xprec) + ',' + convert(varchar(20),c.xscale) + ')' WHEN 'char' THEN t.name + '(' + convert(varchar(20),c.length)+ ')' WHEN 'varchar' THEN t.name + '(' + convert(varchar(20),c.length)+ ')' ELSE t.name + '(' + convert(varchar(20),c.length)+ ')' END as TYPE FROM systypes t,syscolumns c WHERE t.xtype=c.xtype AND c.id = (SELECT id FROM sysobjects WHERE name='MERCHANT') ORDER BY c.colid
panic: runtime error: index out of range [12] with length 11

goroutine 1 [running]:
github.com/gogf/gf-cli/commands/gen.generateStructDefinition(0xc0002bbdd0, 0x8, 0x1)

        /Users/john/Workspace/Go/GOPATH/src/github.com/gogf/gf-cli/commands/gen/gen_model.go:186 +0x427

github.com/gogf/gf-cli/commands/gen.generateModelContentFile(0xdd8000, 0xc000338090, 0xc00001e0d0, 0x8, 
0xc00001e0d0, 0x8, 0xbb1c48, 0xb, 0xbad546, 0x7)

        /Users/john/Workspace/Go/GOPATH/src/github.com/gogf/gf-cli/commands/gen/gen_model.go:107 +0xf0
github.com/gogf/gf-cli/commands/gen.doGenModel(0xc00004c180)

        /Users/john/Workspace/Go/GOPATH/src/github.com/gogf/gf-cli/commands/gen/gen_model.go:88 +0x54a
github.com/gogf/gf-cli/commands/gen.Run()

        /Users/john/Workspace/Go/GOPATH/src/github.com/gogf/gf-cli/commands/gen/gen.go:62 +0x34b
main.main()

        /Users/john/Workspace/Go/GOPATH/src/github.com/gogf/gf-cli/main.go:90 +0x50b

gf-cli run热编译失败

win10系统

>gf -v
GoFrame CLI Tool v0.7.1, https://goframe.org
Install Path: D:\develop\go\bin\gf.exe
Build Detail:
  Go Version:  go1.14
  GF Version:  v1.11.7
  Git Commit:  6bccf7ca382b885f333d14b119829ac4a2fd6a4b
  Build Time:  2020-03-26 15:33:53

启动后热编译
2020-03-29 23:10:42.663 [FATA] 2132: net.Listen error: listen tcp :8080: bind: Only one usage of each socket address (protocol/network address/port) is normally
permitted.

用80和8080端口均一样

gf gen model -p 不生效

如题,生成 model 时,没法加前缀。
我这一个工程可能涉及到多个数据库,现在时生成之后再去修改每个包的前缀。
这种方式会造成没法直接更新 _model.go,比如最近的 ctx 方法。
有计划支持该功能吗?

gf run 同时热编译多个项目

2020-04-02 09:13:19.246 build: .\main.go
2020-04-02 09:13:19.246 rename /tmp\gf-cli\main.exe /tmp\gf-cli\main.exe~: Access is denied.
2020-04-02 09:13:19.246 go build -o /tmp\gf-cli\main.exe  .\main.go
2020-04-02 09:13:20.807 build error:
go build command-line-arguments: open /tmp\gf-cli\main.exe: The process cannot access the file because it is being used by another process.

两个项目都运行 gf run main.go, 然后修改其中一个项目. 测试环境在windows下

版本

GoFrame CLI Tool v0.7.1, https://goframe.org
Build Detail:
  Go Version:  go1.14
  GF Version:  v1.12.1
  Git Commit:  76483c62719736c36992edb7e4cea92c01ca6fc5
  Build Time:  2020-04-01 21:46:21

/tmp\gf-cli\main.exe 临时的可执行文件路径, 可能要修改一下. 比如在路径中加入 gf-app 这个项目相关的文本

能否考虑按版本出离线生成项目的方案

目前gf init应该是在线拉取包的形式生成项目代码框架的。
我们目前的研发环境网络受限,目前仅能访问goproxy.io
在这样的环境下测试了最新版的gf拉取包时报Error: get the project zip md5 failed.

can't run with parameter

my command is gf run main.go server

2020-06-28 11:41:03.356 build: main.go
2020-06-28 11:41:03.356 go build -o /tmp/gf-cli/main server main.go
2020-06-28 11:41:03.370 build error: 
can't load package: named files must be .go files: server
exit status 1

it's ok with go run.

field.Comment undefined (type *gdb.TableField has no field or method Comment)

go build的时候出错!!

sunmoondeMacBook-Pro:gf-cli sunmoon$ go build
# github.com/gogf/gf-cli/commands/gen
commands/gen/gen_model.go:263:37: field.Comment undefined (type *gdb.TableField has no field or method Comment)

重新clone了一份

sunmoondeMacBook-Pro:gf-cli sunmoon$ go build
go: finding github.com/gogf/gf/os latest
go: finding github.com/gogf/gf/os/gbuild latest
build github.com/gogf/gf-cli: cannot load github.com/gogf/gf/os/gbuild: module github.com/gogf/gf@latest found (v1.10.0), but does not contain package github.com/gogf/gf/os/gbuild
sunmoondeMacBook-Pro:gf-cli sunmoon$ 

最新版的cli工具在gf gen model 生成模型后部分方法参数接收个数和参数类型错误

最新版的cli工具在gf gen model 生成模型后部分方法参数接收个数和参数类型错误
gf信息
GoFrame CLI Tool v1.15.0, https://goframe.org
Install Path: /usr/local/bin/gf
Build Detail:
Go Version: go1.15.5
GF Version: v1.14.6
Git Commit: be4a975
Build Time: 2021-01-04 00:01:21
错误文件:_entity.go 62行 Update() 方法
错误文件:
_model.go 101 行 Fields() 方法

还有一些无关紧要的问题
1.更新了cli后,model目录下存在原来生成的文件,不会询问是否覆盖了

辛苦作者大大了

gf-cli build 命令不会自动读取配置文件的 compiler

1. What version of GoFrame are you using?

GoFrame CLI Tool v1.14.5, https://goframe.org
Install Path: /usr/local/bin/gf
Build Detail:
Go Version: go1.15.5
GF Version: v1.14.5
Git Commit: e5b914d
Build Time: 2020-12-14 23:06:09

2. What did you do?

编译配置

[compiler]
    name     = "main"
    version  = "1.0.0"
    arch     = "amd64"
    system   = "linux"
    output   = ""
    path     = "./bin"
    extra    = "-ldflags \"-s -w\""

gf build main.go --pack
2020-12-19 02:40:28.339 gf pack config,public packed/data.go
path 'packed/data.go' is not empty, files might be overwrote, continue? [y/n]: y
2020-12-19 02:40:30.788 done!
2020-12-19 02:40:30.804 start building...
2020-12-19 02:40:30.804 go build -o main main.go
2020-12-19 02:40:34.819 done!

MacOS系统 gf-cli 错误

我是macos系统,我按照 gf install 之后,gf 被安装到了/usr/local/bin/gf,我直接使用/usr/local/bin/gf命令正常,但是直接输入gf 命令的时候报错:
fatal: not a git repository (or any of the parent directories): .git

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.