Code Monkey home page Code Monkey logo

go-mygen's People

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

go-mygen's Issues

数据库表字段大写生成的结构体出问题被截断

表中字段大写导致导出entity后被截断

建议tools里的Capitalize 改为

func (t *Tools) Capitalize(s string) string {
	var upperStr string
	chars := strings.Split(s, "_")
	for _, val := range chars {
		upperStr += strings.ToUpper(val[0:1])+val[1:]
	}
	return upperStr
}

panic: interface conversion: interface {} is nil, not string

Mac操作系统,执行

 ./go-mygen -h localhost -P 3306 -u root -p "Macabc;123" -d dbName

返回结果

2019/12/06 12:42:00 core.go:113: 数据库连接成功
panic: interface conversion: interface {} is nil, not string

goroutine 1 [running]:
main.(*ModelS).findDbTables(0xc0001102a0, 0x16aad40, 0x0, 0x0, 0x0, 0x0)
	/Users/sgfoot/go/src/github.com/yezihack/go-mygen/service.go:39 +0x4f0
main.(*ModelS).GetTableNameAndComment(0xc0001102a0, 0xc00001c2c0, 0x20)
	/Users/sgfoot/go/src/github.com/yezihack/go-mygen/service.go:12 +0x8a
main.Commands(0x13cef93, 0x1)
	/Users/sgfoot/go/src/github.com/yezihack/go-mygen/core.go:123 +0x2c5
main.start.func1(0xc0000d4160, 0x101010101, 0xc0000d4160)
	/Users/sgfoot/go/src/github.com/yezihack/go-mygen/core.go:48 +0x252
github.com/urfave/cli.HandleAction(0x135cf40, 0x13e8530, 0xc0000d4160, 0xc0000ba1e0, 0x0)
	/Users/sgfoot/go/pkg/mod/github.com/urfave/[email protected]/app.go:490 +0xc8
github.com/urfave/cli.(*App).Run(0xc0000a71e0, 0xc0000c0000, 0xb, 0xb, 0x0, 0x0)
	/Users/sgfoot/go/pkg/mod/github.com/urfave/[email protected]/app.go:264 +0x58c
main.start()
	/Users/sgfoot/go/src/github.com/yezihack/go-mygen/core.go:55 +0xa5
main.main()

建议:调整生成的代码的位置。

建议调整生成的代码的位置
即:
entity 目录下,只放与实体相关的代码,即:请求参数,响应数据之类的实体。
model 目录下,只放与数据库相关的代码,即:init.go,config.go,数据库表的model,CURD代码。
我决得只保留这两个包比较好。

反馈一下

No.1: 生成的 entity/db_entity.go 中,默认导入了

"github.com/go-sql-driver/mysql"
"time" 而实际上,entity/db_entity.go 是不需要这些包的。

No.2: 生成的CURD代码中缺少依赖,缺少 entity包,缺少 config包,而实际 import 中并没有导入 entity包,config包。

No.3: 实际删除 assets包,并不影响整个项目生成目标代码,不知是什么原因,这里能详细介绍一下么。

No.4: logic.go 文件中 CreateCURD() 方法内部的方法调用顺序有点问题,所有才出现了 No.2 中的请况。

No.5: 有些方法的的执行好像重复初始化了常量,变量哦。我在看源码的过程中有这种体会。不知事实是不是这样。

No.6: 整体思路很棒,很巧妙的避免了使用反射。可扩展性强,能很方便的将其嵌入到其他组件中。

No.7: bindata.go,logic.go 中这两个文件,您能抽空在你的公众号,或者博客中介绍一下么?

panic: interface conversion: interface {} is nil, not string

2020/08/17 14:41:27 core.go:113: 数据库连接成功
panic: interface conversion: interface {} is nil, not string

goroutine 1 [running]:
main.(*ModelS).findDbTables(0xc000080480, 0x16aad40, 0x0, 0x0, 0x0, 0x0)
/Users/sgfoot/go/src/github.com/yezihack/go-mygen/service.go:39 +0x4f0
main.(*ModelS).GetTableNameAndComment(0xc000080480, 0xc00001e1e0, 0x22)
/Users/sgfoot/go/src/github.com/yezihack/go-mygen/service.go:12 +0x8a
main.Commands(0x13cef93, 0x1)
/Users/sgfoot/go/src/github.com/yezihack/go-mygen/core.go:123 +0x2c5
main.start.func1(0xc0000c0160, 0x101010101, 0xc0000c0160)
/Users/sgfoot/go/src/github.com/yezihack/go-mygen/core.go:48 +0x252
github.com/urfave/cli.HandleAction(0x135cf40, 0x13e8530, 0xc0000c0160, 0xc000080240, 0x0)
/Users/sgfoot/go/pkg/mod/github.com/urfave/[email protected]/app.go:490 +0xc8
github.com/urfave/cli.(*App).Run(0xc0000a3040, 0xc0000120b0, 0xb, 0xb, 0x0, 0x0)
/Users/sgfoot/go/pkg/mod/github.com/urfave/[email protected]/app.go:264 +0x58c
main.start()
/Users/sgfoot/go/src/github.com/yezihack/go-mygen/core.go:55 +0xa5
main.main()
/Users/sgfoot/go/src/github.com/yezihack/go-mygen/main.go:12 +0x86

mysql8.0版本出现这个错误

降级mysql5.7 正常使用

连接数据库报错

执行:

go-mygen -h localhost -P 3306 -u root -p 123456 -d default

报错:

{"level":"ERROR","time":"2019-11-12T14:00:26.187+0800","file":"[email protected]/cmd.go:29","msg":"","service":"go-mygen","err":"interface conversion: interface {} is nil, not string","stack":"goroutine 1 [running]:\nruntime/debug.Stack(0xc000142f48, 0x145cd20, 0xc0000b95f0)\n\t/usr/local/go/src/runtime/debug/stack.go:24 +0x9d\ngithub.com/yezihack/go-mygen.Cmd.func1()\n\t/Users/panbing/mypro/golang/pkg/mod/github.com/yezihack/[email protected]/cmd.go:29 +0x57\npanic(0x145cd20, 0xc0000b95f0)\n\t/usr/local/go/src/runtime/panic.go:679 +0x1b2\ngithub.com/yezihack/go-mygen.(*ModelS).findDbTables(0xc0000b0a20, 0x188b1f8, 0x0, 0x0, 0x0, 0x0)\n\t/Users/panbing/mypro/golang/pkg/mod/github.com/yezihack/[email protected]/services.go:39 +0x4f0\ngithub.com/yezihack/go-mygen.(*ModelS).GetTableNameAndComment(0xc0000b0a20, 0x2c, 0x15)\n\t/Users/panbing/mypro/golang/pkg/mod/github.com/yezihack/[email protected]/services.go:12 +0x8a\ngithub.com/yezihack/go-mygen.Commands(0x7ffeefbff814, 0xd, 0xcea, 0x7ffeefbff841, 0x3, 0x7ffeefbff848, 0x3, 0x7ffeefbff82d, 0x10, 0x14d7800, ...)\n\t/Users/panbing/mypro/golang/pkg/mod/github.com/yezihack/[email protected]/cmd.go:137 +0x287\ngithub.com/yezihack/go-mygen.Cmd.func2(0xc000178000, 0x0, 0xc000172070)\n\t/Users/panbing/mypro/golang/pkg/mod/github.com/yezihack/[email protected]/cmd.go:105 +0x322\ngithub.com/urfave/cli.HandleAction(0x143e260, 0xc00016c000, 0xc000178000, 0xc000178000, 0x0)\n\t/Users/panbing/mypro/golang/pkg/mod/github.com/urfave/[email protected]/app.go:523 +0xbe\ngithub.com/urfave/cli.(*App).Run(0xc000166000, 0xc0000c4000, 0xb, 0xb, 0x0, 0x0)\n\t/Users/panbing/mypro/golang/pkg/mod/github.com/urfave/[email protected]/app.go:285 +0x5df\ngithub.com/yezihack/go-mygen.Cmd()\n\t/Users/panbing/mypro/golang/pkg/mod/github.com/yezihack/[email protected]/cmd.go:113 +0x7dd\nmain.main()\n\t/Users/panbing/mypro/golang/pkg/mod/github.com/yezihack/[email protected]/go-mygen/main.go:7 +0x20\n"}

failed to build

3.1.0beta) go build .

github.com/yezihack/go-mygen

./core.go:69:14: cannot use []*cli.Author literal (type []*cli.Author) as type []cli.Author in assignment
./core.go:75:15: cannot use []*cli.Command literal (type []*cli.Command) as type []cli.Command in assignment

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.