go-sword
go-sword copied to clipboard
[Vssue]Vssue Dev
https://sunshinev.github.io/go-sword-home/forum
First
欢迎大家在这里讨论问题
如果使用过程中,有任何问题,也可以在这里反馈
支持一下
@andrewlcgu
支持一下
感谢支持
cannot use data["id"] (type int) as type int64 in field value
我的jianbi建表语句,请问是有什么冲突吗
@lizeyun
cannot use data["id"] (type int) as type int64 in field value
我的jianbi建表语句,请问是有什么冲突吗
这个可能是解析表结构的时候,没有解析bigint导致的。建表的时候,可以使用int类型试下
@lizeyun
cannot use data["id"] (type int) as type int64 in field value
我的jianbi建表语句,请问是有什么冲突吗
底层的db to struct解析bigint的时候,转换成了int64
为什么用go做这个代码生成有一些问题呢。因为数据库转换结构体的时候,有个类型的映射。生成前端代码的时候,JavaScript也要做类型映射。所以涉及到数据库、golang、js的类型对应。
在建表的时候尽可能的使用
数据库type | golang |
---|---|
"tinyint", "int", "smallint", "mediumint" | golangInt |
"bigint" | golangInt64 |
"char", "enum", "varchar", "longtext", "mediumtext", "text", "tinytext", "json" | "string" |
"date", "datetime", "time", "timestamp" | golangTime |
"decimal", "double" | golangFloat64 |
"float" | golangFloat32 |
"binary", "blob", "longblob", "mediumblob", "varbinary" | golangByteArray |
v0.0.7 修改了生成项目的数据连接无法连接远程数据库的问题,增加了host:port
db, err := gorm.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8&parseTime=True&loc=Local", d.User, d.Password, d.Host, d.Port, d.Database))
@sunshinev some problem about the new project by go-sword generate :
1: id/created_at/updated_at this column is required in table and it will influences the frontend style
2: the model generate is wrong which i need to modify the package model
@sunshinev some problem about the new project by go-sword generate : 1: id/created_at/updated_at this column is required in table and it will influences the frontend style
2: the model generate is wrong which i need to modify the package model
More interesting when i add some the three column : then deploy the project ;it didn't Reproduce the second problem
@Alias4bb
@sunshinev some problem about the new project by go-sword generate : 1: id/created_at/updated_at this column is required in table and it will influences the frontend style
2: the model generate is wrong which i need to modify the package model
More interesting when i add some the three column : then deploy the project ;it didn't Reproduce the second problem
当初设计的时候,为了满足生成的页面结构统一,所以 id/created_at/updated_at 这三个字段是必须的
v1.0.0更新
- 底层db转换struct进行了重写
- 使用切片代替map,解决字段排序问题
- 服务启动进行了重写,添加config包来解决全局配置GlobalConfig
- 调整后的结构体主要有int32/string/float64/time.Time四种类型