Code Monkey home page Code Monkey logo

gormt's Issues

一直生成失败,这是啥还有python问题?


goroutine 1 [running]:
github.com/xxjwxc/gormt/data/view/model.getTypeName(0xc000028cb0, 0x8, 0x1570c25, 0x1)
	/Users/Django/www/tools/gormt/data/view/model/common.go:47 +0x218
github.com/xxjwxc/gormt/data/view/model.(*_Model).genTableElement(0xc000565cd0, 0xc000238700, 0x7, 0x8, 0xc000551180, 0xb, 0x10)
	/Users/Django/www/tools/gormt/data/view/model/model.go:46 +0xc39
github.com/xxjwxc/gormt/data/view/model.(*_Model).generate(0xc000565cd0, 0xc00016a092, 0x5)
	/Users/Django/www/tools/gormt/data/view/model/model.go:29 +0x1fa
github.com/xxjwxc/gormt/data/view/model.Generate(...)
	/Users/Django/www/tools/gormt/data/view/model/model.go:19
github.com/xxjwxc/gormt/data/view/gtools.Execute()
	/Users/Django/www/tools/gormt/data/view/gtools/gtools.go:25 +0x148
github.com/xxjwxc/gormt/data/cmd.glob..func1(0x1a285c0, 0x1a6ce10, 0x0, 0x0)
	/Users/Django/www/tools/gormt/data/cmd/cmd.go:27 +0x20
github.com/spf13/cobra.(*Command).execute(0x1a285c0, 0xc000094010, 0x0, 0x0, 0x1a285c0, 0xc000094010)
	/Users/Django/www/GOPATH/pkg/mod/github.com/spf13/[email protected]/command.go:830 +0x2aa
github.com/spf13/cobra.(*Command).ExecuteC(0x1a285c0, 0x0, 0x0, 0x0)
	/Users/Django/www/GOPATH/pkg/mod/github.com/spf13/[email protected]/command.go:914 +0x2fb
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/Django/www/GOPATH/pkg/mod/github.com/spf13/[email protected]/command.go:864
github.com/xxjwxc/gormt/data/cmd.Execute()
	/Users/Django/www/tools/gormt/data/cmd/cmd.go:35 +0x2d
main.main()
	/Users/Django/www/tools/gormt/main.go:6 +0x20

tinyint(4)

panic: type (tinyint(4)) not match in any way.

无法生成json tag

工具很好用,但是遇见个问题
如果下图配置,始终生成不了json tag,是我配置有问题吗?
image
image

type (float unsigned) not match in any way.maybe need to add on

panic: type (float unsigned) not match in any way.maybe need to add on (https://github.com/xxjwxc/gormt/blob/master/data/view/cnf/def.go)

goroutine 1 [running]:
github.com/xxjwxc/gormt/data/view/model.getTypeName(0xc0003b8ee0, 0xe, 0x15e4806, 0x1)
        /Users/xxj/work/workspace/github/xxjwxc/gormt/data/view/model/common.go:61 +0x218
github.com/xxjwxc/gormt/data/view/model.(*_Model).genTableElement(0xc0002edc78, 0xc000191800, 0xb, 0x11, 0xc00039e380, 0x8, 0x8)
        /Users/xxj/work/workspace/github/xxjwxc/gormt/data/view/model/model.go:83 +0xcff
github.com/xxjwxc/gormt/data/view/model.(*_Model).GetPackage(0xc0002edc78, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /Users/xxj/work/workspace/github/xxjwxc/gormt/data/view/model/model.go:55 +0x25c
github.com/xxjwxc/gormt/data/view/model.(*_Model).generate(0xc0002edc78, 0xcea, 0xc0001b9158)
        /Users/xxj/work/workspace/github/xxjwxc/gormt/data/view/model/model.go:67 +0x3e
github.com/xxjwxc/gormt/data/view/model.Generate(0xc0001b9198, 0x8, 0xc0001b8e5a, 0x6, 0xc000300000, 0x46, 0x87, 0x87, 0x0, 0x1602672, ...)
        /Users/xxj/work/workspace/github/xxjwxc/gormt/data/view/model/model.go:31 +0xc3
github.com/xxjwxc/gormt/data/view/gtools.showCmd()
        /Users/xxj/work/workspace/github/xxjwxc/gormt/data/view/gtools/gtools.go:37 +0xb7
github.com/xxjwxc/gormt/data/view/gtools.Execute()
        /Users/xxj/work/workspace/github/xxjwxc/gormt/data/view/gtools/gtools.go:22 +0x38
github.com/xxjwxc/gormt/data/cmd.glob..func1(0x1b1ba60, 0x1b6f408, 0x0, 0x0)
        /Users/xxj/work/workspace/github/xxjwxc/gormt/data/cmd/cmd.go:32 +0x20
github.com/spf13/cobra.(*Command).execute(0x1b1ba60, 0xc00001e1b0, 0x0, 0x0, 0x1b1ba60, 0xc00001e1b0)
        /Users/xxj/work/path/pkg/mod/github.com/spf13/[email protected]/command.go:830 +0x29d
github.com/spf13/cobra.(*Command).ExecuteC(0x1b1ba60, 0x0, 0x0, 0x0)
        /Users/xxj/work/path/pkg/mod/github.com/spf13/[email protected]/command.go:914 +0x2fb
github.com/spf13/cobra.(*Command).Execute(...)
        /Users/xxj/work/path/pkg/mod/github.com/spf13/[email protected]/command.go:864
github.com/xxjwxc/gormt/data/cmd.Execute()
        /Users/xxj/work/workspace/github/xxjwxc/gormt/data/cmd/cmd.go:40 +0x2d
main.main()
        /Users/xxj/work/workspace/github/xxjwxc/gormt/main.go:6 +0x20

数据表主键为id,序列化为jason时,不能输出主键?

type User struct {
ID int gorm:"primary_key;column:id;type:int(10) unsigned;not null" json:"-" // ID
Account string gorm:"column:account;type:varchar(255);not null" json:"account" // 账号
}

===============
如上,为什么" json:"-"` // ID,这样的话该结构序列化时,无法生成该字段,怎么解决?

Cannot get latest version: module contains a go.mod file, so module path should be github.com/xxjwxc/gormt/v3

Background

The github.com/xxjwxc/gormt uses Go modules and the current release version is v3. And it’s module path is "github.com/xxjwxc/gormt", instead of "github.com/xxjwxc/gormt/v3". It must comply with the specification of "Releasing Modules for v2 or higher" available in the Modules documentation. Quoting the specification:

A package that has opted in to modules must include the major version in the import path to import any v2+ modules
To preserve import compatibility, the go command requires that modules with major version v2 or later use a module path with that major version as the final element. For example, version v2.0.0 of example.com/m must instead use module path example.com/m/v2.
https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher

Steps to Reproduce

GO111MODULE=on, run go get targeting any version >= v2.0.0 of the xxjwxc/gormt:

$ go get github.com/xxjwxc/[email protected]
go: finding github.com/xxjwxc/gormt v3.0.6
go: finding github.com/xxjwxc/gormt v3.0.6
go get github.com/xxjwxc/[email protected]: github.com/xxjwxc/[email protected]: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v3

run go get github.com/xxjwxc/gormt, the version will stuck in v1.1.2:

$go get github.com/xxjwxc/gormt
go: downloading github.com/xxjwxc/gormt v1.1.2
go: github.com/xxjwxc/gormt upgrade => v1.1.2 

SO anyone using Go modules will not be able to easily use any newer version of xxjwxc/gormt.

Solution

1. Kill the go.mod files, rolling back to GOPATH.

This would push them back to not being managed by Go modules (instead of incorrectly using Go modules).
Ensure compatibility for downstream module-aware projects and module-unaware projects projects

2. Fix module path to strictly follow SIV rules.

Patch the go.mod file to declare the module path as github.com/xxjwxc/gormt/v3 as per the specs. And adjust all internal imports.
The downstream projects might be negatively affected in their building if they are module-unaware (Go versions older than 1.9.7 and 1.10.3; Or use third-party dependency management tools, such as: Dep, glide,govendor…).

If you don't want to break the above repos. This method can provides better backwards-compatibility.
Release a v2 or higher module through the major subdirectory strategy: Create a new v3 subdirectory (github.com/xxjwxc/gormt/v3) and place a new go.mod file in that subdirectory. The module path must end with /v3. Copy or move the code into the v3 subdirectory. Update import statements within the module to also use /v3 (import "github.com/xxjwxc/gormt/v3/…"). Tag the release with v3.x.y.

3. Suggest your downstream module users use hash instead of a version tag.

If the standard rule of go modules conflicts with your development mode. Or not intended to be used as a library and does not make any guarantees about the API. So you can’t comply with the specification of "Releasing Modules for v2 or higher" available in the Modules documentation.
Regardless, since it's against one of the design choices of Go, it'll be a bit of a hack. Instead of go get github.com/xxjwxc/gormt@version-tag, module users need to use this following way to get the xxjwxc/gormt:
(1) Search for the tag you want (in browser)
(2) Get the commit hash for the tag you want
(3) Run go get github.com/xxjwxc/gormt@commit-hash
(4) Edit the go.mod file to put a comment about which version you actually used
This will make it difficult for module users to get and upgrade xxjwxc/gormt.

[*] You can see who will be affected here: [5 module users, e.g., weblazy/orm, psychopurp/Finders-Server, olongfen/note]
https://github.com/search?q=%22github.com%2Fxxjwxc%2Fgormt%22+filename%3Ago.mod&type=Code

Summary

You can make a choice to fix DM issues by balancing your own development schedules/mode against the affects on the downstream projects.

For this issue, Solution 2 can maximize your benefits and with minimal impacts to your downstream projects the ecosystem.

References

关于SDK

请问作者有考虑做成SDK模式吗, 方便集成到自己程序里

execute fail

panic: type (tinyint(2)) not match in any way.

如果表太多,内存不足

`panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1385c66]

goroutine 1 [running]:
database/sql.(*Rows).close(0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2976 +0x66
database/sql.(*Rows).Close(0x0, 0xc0000a2d00, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2972 +0x33
panic(0x14d4fc0, 0x1a1eea0)
/usr/local/Cellar/go/1.12.8/libexec/src/runtime/panic.go:522 +0x1b5
database/sql.(*Rows).close(0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2976 +0x66
database/sql.(*Rows).Close(0x0, 0xc0005078c0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2972 +0x33
panic(0x14d4fc0, 0x1a1eea0)
/usr/local/Cellar/go/1.12.8/libexec/src/runtime/panic.go:522 +0x1b5
database/sql.(*Rows).close(0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2976 +0x66
database/sql.(*Rows).Close(0x0, 0xc000507d60, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2972 +0x33
panic(0x14d4fc0, 0x1a1eea0)
/usr/local/Cellar/go/1.12.8/libexec/src/runtime/panic.go:522 +0x1b5
database/sql.(*Rows).close(0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2976 +0x66
database/sql.(*Rows).Close(0x0, 0xc0006ffb80, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2972 +0x33
panic(0x14d4fc0, 0x1a1eea0)
/usr/local/Cellar/go/1.12.8/libexec/src/runtime/panic.go:522 +0x1b5
database/sql.(*Rows).close(0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2976 +0x66
database/sql.(*Rows).Close(0x0, 0xc0006ffd00, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2972 +0x33
panic(0x14d4fc0, 0x1a1eea0)
/usr/local/Cellar/go/1.12.8/libexec/src/runtime/panic.go:522 +0x1b5
database/sql.(*Rows).close(0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2976 +0x66
database/sql.(*Rows).Close(0x0, 0xc0006ffd60, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2972 +0x33
panic(0x14d4fc0, 0x1a1eea0)
/usr/local/Cellar/go/1.12.8/libexec/src/runtime/panic.go:522 +0x1b5
database/sql.(*Rows).close(0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2976 +0x66
database/sql.(*Rows).Close(0x0, 0xc0007012e0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2972 +0x33
panic(0x14d4fc0, 0x1a1eea0)
/usr/local/Cellar/go/1.12.8/libexec/src/runtime/panic.go:522 +0x1b5
database/sql.(*Rows).close(0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2976 +0x66
database/sql.(*Rows).Close(0x0, 0xc0003f2c20, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2972 +0x33
panic(0x14d4fc0, 0x1a1eea0)
/usr/local/Cellar/go/1.12.8/libexec/src/runtime/panic.go:522 +0x1b5
database/sql.(*Rows).close(0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2976 +0x66
database/sql.(*Rows).Close(0x0, 0xc0005581a0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2972 +0x33
panic(0x14d4fc0, 0x1a1eea0)
/usr/local/Cellar/go/1.12.8/libexec/src/runtime/panic.go:522 +0x1b5
database/sql.(*Rows).close(0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2976 +0x66
database/sql.(*Rows).Close(0x0, 0xc000558420, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2972 +0x33
panic(0x14d4fc0, 0x1a1eea0)
/usr/local/Cellar/go/1.12.8/libexec/src/runtime/panic.go:522 +0x1b5
database/sql.(*Rows).close(0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2976 +0x66
database/sql.(*Rows).Close(0x0, 0xc0003f2e80, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2972 +0x33
panic(0x14d4fc0, 0x1a1eea0)
/usr/local/Cellar/go/1.12.8/libexec/src/runtime/panic.go:522 +0x1b5
database/sql.(*Rows).close(0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2976 +0x66
database/sql.(*Rows).Close(0x0, 0xc000701ee0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2972 +0x33
panic(0x14d4fc0, 0x1a1eea0)
/usr/local/Cellar/go/1.12.8/libexec/src/runtime/panic.go:522 +0x1b5
database/sql.(*Rows).close(0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2976 +0x66
database/sql.(*Rows).Close(0x0, 0xc00052e300, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2972 +0x33
panic(0x14d4fc0, 0x1a1eea0)
/usr/local/Cellar/go/1.12.8/libexec/src/runtime/panic.go:522 +0x1b5
database/sql.(*Rows).close(0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2976 +0x66
database/sql.(*Rows).Close(0x0, 0xc0003f36e0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2972 +0x33
panic(0x14d4fc0, 0x1a1eea0)
/usr/local/Cellar/go/1.12.8/libexec/src/runtime/panic.go:522 +0x1b5
database/sql.(*Rows).close(0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2976 +0x66
database/sql.(*Rows).Close(0x0, 0xc000558e40, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2972 +0x33
panic(0x14d4fc0, 0x1a1eea0)
/usr/local/Cellar/go/1.12.8/libexec/src/runtime/panic.go:522 +0x1b5
database/sql.(*Rows).close(0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2976 +0x66
database/sql.(*Rows).Close(0x0, 0xc000559560, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2972 +0x33
panic(0x14d4fc0, 0x1a1eea0)
/usr/local/Cellar/go/1.12.8/libexec/src/runtime/panic.go:522 +0x1b5
database/sql.(*Rows).close(0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2976 +0x66
database/sql.(*Rows).Close(0x0, 0xc0003f3980, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2972 +0x33
panic(0x14d4fc0, 0x1a1eea0)
/usr/local/Cellar/go/1.12.8/libexec/src/runtime/panic.go:522 +0x1b5
database/sql.(*Rows).close(0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2976 +0x66
database/sql.(*Rows).Close(0x0, 0xc000428080, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2972 +0x33
panic(0x14d4fc0, 0x1a1eea0)
/usr/local/Cellar/go/1.12.8/libexec/src/runtime/panic.go:522 +0x1b5
database/sql.(*Rows).close(0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2976 +0x66
database/sql.(*Rows).Close(0x0, 0xc0003f3e80, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2972 +0x33
panic(0x14d4fc0, 0x1a1eea0)
/usr/local/Cellar/go/1.12.8/libexec/src/runtime/panic.go:522 +0x1b5
database/sql.(*Rows).close(0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2976 +0x66
database/sql.(*Rows).Close(0x0, 0xc0004282c0, 0x0)
/usr/local/Cellar/go/1.12.8/libexec/src/database/sql/sql.go:2972 +0x33
`

修改配置报错

λ gormt.exe -H=127.0.0.1 -d=base_document_queue -p=123456 -u=zrd --port=3306 -F=true
2020/08/25 14:26:55 using database info:
2020/08/25 14:26:55 {
     "Host": "127.0.0.1",
     "Port": 3306,
     "Username": "zrd",
     "Password": "123456",
     "Database": "base_document_queue"
}
panic: type (bit(10)) not match in any way.maybe need to add on (https://github.com/xxjwxc/gormt/blob/master/data/view/cnf/def.go)

当表名为order或者match时,无法生成对应的struct

以下为程序生成的日志:
(/Users/jianghongchao/Downloads/gormt-master/data/view/model/genmysql/genmysql.go:113) [2020-04-30 15:59:20] [Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'match' at line 1]
goroutine 18 [running]:
runtime/debug.Stack(0xc0000119a0, 0xc0002ac6c0, 0x116)
/usr/local/go/src/runtime/debug/stack.go:24 +0x9d
github.com/xxjwxc/public/mylog.SaveError(0xc0002ac480, 0x114, 0x160aa2a, 0x3)
/Users/jianghongchao/go/pkg/mod/github.com/xxjwxc/[email protected]/mylog/mylog.go:100 +0x382
github.com/xxjwxc/public/mysqldb.DbLog.Print(0x0, 0x0, 0xc000380a80, 0x3, 0x3)
/Users/jianghongchao/go/pkg/mod/github.com/xxjwxc/[email protected]/mysqldb/log.go:36 +0x99
github.com/jinzhu/gorm.(*DB).print(0xc0003b40d0, 0xc000380a80, 0x3, 0x3)
/Users/jianghongchao/go/pkg/mod/github.com/jinzhu/[email protected]/main.go:841 +0x52
created by github.com/jinzhu/gorm.(*DB).AddError
/Users/jianghongchao/go/pkg/mod/github.com/jinzhu/[email protected]/main.go:781 +0x2fc

数据表主键为id,序列化为jason时,不能输出主键?

type User struct {
ID int gorm:"primary_key;column:id;type:int(10) unsigned;not null" json:"-" // ID
Account string gorm:"column:account;type:varchar(255);not null" json:"account" // 账号
}

===============
如上,为什么" json:"-"` // ID,这样的话该结构序列化时,无法生成该字段,怎么解决?

有计划生成数据库表中现有数据的插入语句吗

有时候数据库中有些初始数据在程序初始化的时候需要导入,问一下作者有没有计划做对旧数据库表中现有数据生成导入新数据库表中的代码功能。

再次感谢作者提供这么好用的功能

this is my question,what should i do

goroutine 1 [running]:
github.com/xxjwxc/gormt/data/view/model.getTypeName(0xc0003fc790, 0x8, 0x1560455, 0x1)
/Users/apple/go/src/github.com/xxjwxc/gormt/data/view/model/common.go:47 +0x218
github.com/xxjwxc/gormt/data/view/model.(_Model).genTableElement(0xc000555cf8, 0xc00047a000, 0x14, 0x27, 0xc00014a700, 0x7, 0x8)
/Users/apple/go/src/github.com/xxjwxc/gormt/data/view/model/model.go:46 +0xc44
github.com/xxjwxc/gormt/data/view/model.(
_Model).generate(0xc000555cf8, 0x7ffeefbffab8, 0x6)
/Users/apple/go/src/github.com/xxjwxc/gormt/data/view/model/model.go:29 +0x1f9
github.com/xxjwxc/gormt/data/view/model.Generate(...)
/Users/apple/go/src/github.com/xxjwxc/gormt/data/view/model/model.go:19
github.com/xxjwxc/gormt/data/view/gtools.Execute()
/Users/apple/go/src/github.com/xxjwxc/gormt/data/view/gtools/gtools.go:25 +0x14a
github.com/xxjwxc/gormt/data/cmd.glob..func1(0x1a41e60, 0xc00033e420, 0x0, 0x6)
/Users/apple/go/src/github.com/xxjwxc/gormt/data/cmd/cmd.go:27 +0x20
github.com/spf13/cobra.(*Command).execute(0x1a41e60, 0xc0000b0010, 0x6, 0x6, 0x1a41e60, 0xc0000b0010)

报错了。type (int unsigned) not match in any way.maybe need to add on (https://github.com/xxjwxc/gormt/blob/master/data/view/cnf/def.go)

panic: type (int unsigned) not match in any way.maybe need to add on (https://github.com/xxjwxc/gormt/blob/master/data/view/cnf/def.go)

goroutine 1 [running]:
github.com/xxjwxc/gormt/data/view/model.getTypeName(0xc000392c14, 0xc, 0x1607886, 0x1)
/Users/eric/Downloads/gormt-3.0.3/data/view/model/common.go:51 +0x218
github.com/xxjwxc/gormt/data/view/model.(_Model).genTableElement(0xc000375c10, 0xc00024f500, 0x7, 0x8, 0x1, 0xc0004310e0, 0x0)
/Users/eric/Downloads/gormt-3.0.3/data/view/model/model.go:81 +0xd14
github.com/xxjwxc/gormt/data/view/model.(
_Model).GetPackage(0xc000375c10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/eric/Downloads/gormt-3.0.3/data/view/model/model.go:53 +0x23d
github.com/xxjwxc/gormt/data/view/model.(*_Model).generate(0xc000375c10, 0xc00017d030, 0x9)
/Users/eric/Downloads/gormt-3.0.3/data/view/model/model.go:65 +0x3e
github.com/xxjwxc/gormt/data/view/model.Generate(0xc00017d0a0, 0x7, 0xc00017cd9a, 0x5, 0xc00037e900, 0xb, 0x10, 0x10, 0xc, 0xb, ...)
/Users/eric/Downloads/gormt-3.0.3/data/view/model/model.go:31 +0xc3
github.com/xxjwxc/gormt/data/view/gtools.showCmd()
/Users/eric/Downloads/gormt-3.0.3/data/view/gtools/gtools.go:36 +0xb7
github.com/xxjwxc/gormt/data/view/gtools.Execute()
/Users/eric/Downloads/gormt-3.0.3/data/view/gtools/gtools.go:21 +0x38
github.com/xxjwxc/gormt/data/cmd.glob..func1(0x1b39260, 0xc00030b540, 0x0, 0x1)
/Users/eric/Downloads/gormt-3.0.3/data/cmd/cmd.go:30 +0x20
github.com/spf13/cobra.(*Command).execute(0x1b39260, 0xc0000c4030, 0x1, 0x1, 0x1b39260, 0xc0000c4030)
/Users/eric/GoProject/GoResource/pkg/mod/github.com/spf13/[email protected]/command.go:830 +0x2aa
github.com/spf13/cobra.(*Command).ExecuteC(0x1b39260, 0x0, 0x0, 0x0)
/Users/eric/GoProject/GoResource/pkg/mod/github.com/spf13/[email protected]/command.go:914 +0x2fb
github.com/spf13/cobra.(*Command).Execute(...)
/Users/eric/GoProject/GoResource/pkg/mod/github.com/spf13/[email protected]/command.go:864
github.com/xxjwxc/gormt/data/cmd.Execute()
/Users/eric/Downloads/gormt-3.0.3/data/cmd/cmd.go:38 +0x2d
main.main()
/Users/eric/Downloads/gormt-3.0.3/main.go:6 +0x20

不支持smallint类型

{"Host":"127.0.0.1","Port":3306,"Username":"root","Password":"123456","Database":"xjaccountsdb"}
panic: type (smallint(6)) not match in any way.maybe need to add on ()

GetByOption/GetByOptions系列函数功能无效

win10环境下,在gin这个web server下引入gormt生成的代码,调用方式跟测试案例类似,即:
userMgr := model.UserMgr(db)
userMgr.GetByOption(userMgr.WithAccount("aa"), userMgr.WithPwd("bb"))
发觉返回数据不正确,经调试,发觉GetByOption函数内部,调用apply的时候,拿不到传入进去的参数"aa"和"bb",调试查看变量的时候,提示报错 error code 299—— Only part of a ReadProcessMemory or WriteProcessMemory request was completed。而且最终得到的options.options这个map里存在Account和Pwd的key,但是里面的内容都是"",不知道具体是什么原因。

how to use

大神,你这个文档写的看完也不知道怎么用,我的理解是:1.配置好yml 2.go build根目录下的main.go 但是貌似会编译失败 提示:go: github.com/go-playground/[email protected]: Get https://proxy.golang.org/github.com/go-playground/universal-translator/@v/v0.17.0.mod: dial tcp [2404:6800:4008:803::2011]:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. 求大神回复指导下

不支持数据库是空密码

error info: Key: 'MysqlDbInfo.Password' Error:Field validation for 'Password' failed on the 'required' tag Key: 'MysqlDbInfo.Password' Error:Field validation for 'Password' failed on the 'required' tag

can not parse cmd flags

./gormt -H=127.0.0.1 --port=3306 -d=db_order -p=Jd8fW -u=root -o=models -s=true

Can't read cmd: using (-h, --help) to get more imfo
error info: Key: 'MysqlDbInfo.Port' Error:Field validation for 'Port' failed on the 'required' tag Key: 'MysqlDbInfo.Port' Error:Field validation for 'Port' failed on the 'required' tag

"undefined: tools.GetJsonStr" when install gromt by go get

go: github.com/xxjwxc/gormt upgrade => v1.1.2
go: google.golang.org/appengine upgrade => v1.6.6
go: github.com/leodido/go-urn upgrade => v1.2.0
go: github.com/gookit/color upgrade => v1.2.5
go: github.com/spf13/cobra upgrade => v1.0.0
go: github.com/go-playground/universal-translator upgrade => v0.17.0
go: github.com/spf13/pflag upgrade => v1.0.5
go: gopkg.in/go-playground/validator.v9 upgrade => v9.31.0
go: github.com/jinzhu/gorm upgrade => v1.9.14
go: github.com/go-playground/locales upgrade => v0.13.0
go: github.com/go-sql-driver/mysql upgrade => v1.5.0
go: github.com/xxjwxc/public upgrade => v0.0.0-20200621092001-382926a82a5f
go: github.com/BurntSushi/toml upgrade => v0.3.1
go: go.uber.org/zap upgrade => v1.15.0
go: github.com/pkg/errors upgrade => v0.9.1
go: go.uber.org/multierr upgrade => v1.5.0
go: go.uber.org/atomic upgrade => v1.6.0
# github.com/xxjwxc/gormt/data/cmd
go/pkg/mod/github.com/xxjwxc/[email protected]/data/cmd/cmd.go:73:15: undefined: tools.GetJsonStr

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.