liuhao2050 / to-go-struct-intellij-plugin Goto Github PK
View Code? Open in Web Editor NEWThis tool can converts JSON/SQL to a Go type definition.
License: Apache License 2.0
This tool can converts JSON/SQL to a Go type definition.
License: Apache License 2.0
Dependencies of Convert JSON/SQL to GO Struct 1.0.7 specified in plugin.xml are resolved with respect to IntelliJ IDEA Ultimate IU-212.5080.55 (2021.2.1). Java 11.0.11 was used for verification.
to-go-struct 1.0.7
--- com.intellij 212.5080.55 [declaring module com.intellij.modules.lang]
+--- (failed) (optional) module intellij.profiler.ultimate: Plugins declaring module 'intellij.profiler.ultimate' are not found in Marketplace https://plugins.jetbrains.com
+--- (failed) (optional) module intellij.profiler.common: Plugins declaring module 'intellij.profiler.common' are not found in Marketplace https://plugins.jetbrains.com
--- (failed) (optional) module intellij.profiler.ultimate.ideaAsyncProfiler: Plugins declaring module 'intellij.profiler.ultimate.ideaAsyncProfiler' are not found in Marketplace https://plugins.jetbrains.com
This happens when we use references keyword to reference foreign keys.
com.alibaba.druid.sql.parser.ParserException: syntax error, expect LPAREN, actual COMMA pos 161, line 5, column 46, token COMMA
at com.alibaba.druid.sql.parser.SQLExprParser.accept(SQLExprParser.java:2742)
at com.alibaba.druid.sql.parser.SQLExprParser.parseReference(SQLExprParser.java:2912)
at com.alibaba.druid.sql.parser.SQLExprParser.parseColumnRest(SQLExprParser.java:2814)
at com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser.parseColumnRest(MySqlExprParser.java:620)
at com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser.parseColumn(MySqlExprParser.java:542)
at com.alibaba.druid.sql.parser.SQLCreateTableParser.parseCreateTable(SQLCreateTableParser.java:108)
at com.alibaba.druid.sql.parser.SQLCreateTableParser.parseCreateTable(SQLCreateTableParser.java:47)
at entry.SQLStructBuilder.gen(SQLStructBuilder.kt:41)
at TextCopyForm.gen(TextCopyForm.java:84)
at Runner.run(Runner.kt:13)
at ConvertSQLAction.actionPerformed(ConvertSQLAction.java:16)
at com.intellij.openapi.actionSystem.ex.ActionUtil.doPerformActionOrShowPopup(ActionUtil.java:323)
at com.intellij.openapi.actionSystem.ex.ActionUtil.lambda$performActionDumbAwareWithCallbacks$4(ActionUtil.java:302)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks(ActionUtil.java:346)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAwareWithCallbacks(ActionUtil.java:302)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$performAction$5(ActionMenuItem.java:296)
at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:226)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.performAction(ActionMenuItem.java:289)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$new$0(ActionMenuItem.java:64)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$fireActionPerformed$4(ActionMenuItem.java:111)
at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105)
at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:94)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:111)
at com.intellij.ui.plaf.beg.BegMenuItemUI.doClick(BegMenuItemUI.java:526)
at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:558)
at java.desktop/java.awt.Component.processMouseEvent(Component.java:6648)
at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3392)
at java.desktop/java.awt.Component.processEvent(Component.java:6413)
at java.desktop/java.awt.Container.processEvent(Container.java:2266)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5022)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4854)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4948)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4575)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4516)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2802)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4854)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:781)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:730)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:724)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:754)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:752)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:751)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:909)
at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.java:831)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:753)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$5(IdeEventQueue.java:437)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:772)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:436)
at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:113)
at com.intellij.ide.IdeEventQueue.performActivity(IdeEventQueue.java:615)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:434)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:813)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:480)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
当不选择任何文本,右键菜单选择 Convert SQL to GO 时,触发如下异常输出:
GoLand:2020.2.3 2020.7319.61
Plugin:1.0.7
com.alibaba.druid.sql.parser.ParserException: syntax error, error in :'syscall.Mount', expect CREATE, actual IDENTIFIER pos 7, line 1, column 1, token IDENTIFIER syscall
at com.alibaba.druid.sql.parser.SQLParser.printError(SQLParser.java:287)
at com.alibaba.druid.sql.parser.SQLParser.accept(SQLParser.java:295)
at com.alibaba.druid.sql.parser.SQLCreateTableParser.parseCreateTable(SQLCreateTableParser.java:63)
at com.alibaba.druid.sql.parser.SQLCreateTableParser.parseCreateTable(SQLCreateTableParser.java:47)
at entry.SQLStructBuilder.gen(SQLStructBuilder.kt:41)
at TextCopyForm.gen(TextCopyForm.java:84)
at Runner.run(Runner.kt:13)
at ConvertSQLAction.actionPerformed(ConvertSQLAction.java:16)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:282)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.lambda$actionPerformed$0(ActionMenuItem.java:296)
at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:281)
at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:77)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:285)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$fireActionPerformed$0(ActionMenuItem.java:112)
at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:94)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:112)
at com.intellij.ui.plaf.beg.BegMenuItemUI.doClick(BegMenuItemUI.java:519)
at com.intellij.ui.plaf.beg.BegMenuItemUI.access$300(BegMenuItemUI.java:36)
at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:541)
at java.desktop/java.awt.Component.processMouseEvent(Component.java:6654)
at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3345)
at java.desktop/java.awt.Component.processEvent(Component.java:6419)
at java.desktop/java.awt.Container.processEvent(Container.java:2263)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5029)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4861)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2773)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4861)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:778)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:751)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:749)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:748)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:971)
at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.java:906)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:838)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:452)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:744)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:451)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:802)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:505)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
选择了文本,但是内容是非预期的字符串 "cmd.Stdout = os.Stdout" 时,触发如下异常输出:
com.alibaba.druid.sql.parser.ParserException: syntax error, error in :'cmd.Stdout = os.Stdout', expect CREATE, actual IDENTIFIER pos 3, line 1, column 1, token IDENTIFIER cmd
at com.alibaba.druid.sql.parser.SQLParser.printError(SQLParser.java:287)
at com.alibaba.druid.sql.parser.SQLParser.accept(SQLParser.java:295)
at com.alibaba.druid.sql.parser.SQLCreateTableParser.parseCreateTable(SQLCreateTableParser.java:63)
at com.alibaba.druid.sql.parser.SQLCreateTableParser.parseCreateTable(SQLCreateTableParser.java:47)
at entry.SQLStructBuilder.gen(SQLStructBuilder.kt:41)
at TextCopyForm.gen(TextCopyForm.java:84)
at Runner.run(Runner.kt:13)
at ConvertSQLAction.actionPerformed(ConvertSQLAction.java:16)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:282)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.lambda$actionPerformed$0(ActionMenuItem.java:296)
at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:281)
at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:77)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:285)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$fireActionPerformed$0(ActionMenuItem.java:112)
at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:94)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:112)
at com.intellij.ui.plaf.beg.BegMenuItemUI.doClick(BegMenuItemUI.java:519)
at com.intellij.ui.plaf.beg.BegMenuItemUI.access$300(BegMenuItemUI.java:36)
at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:541)
at java.desktop/java.awt.Component.processMouseEvent(Component.java:6654)
at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3345)
at java.desktop/java.awt.Component.processEvent(Component.java:6419)
at java.desktop/java.awt.Container.processEvent(Container.java:2263)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5029)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4861)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2773)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4861)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:778)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:751)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:749)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:748)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:971)
at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.java:906)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:838)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:452)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:744)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:451)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:802)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:505)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
转换后字段名不符合golang命名规范,例如驼峰命名转换后只有首字母是大写,其他都变成了小写,还有的就是建议支持自定义结构体反引号内的sql映射的key,比如 gorm、db等等。还有个地方就是plugin.xml中你设置适用ide版本最高为202,导致最新版goland无法安装也无法在ide里搜索到此插件
如int unsigned转换后是int
首先感谢作者,插件很方便。
希望能够在后续开发过程中,实现一个可选的增强功能。
对于 可为 null 类型的字段,可以映射为 sql.NullXXX 类型。
假设输入为
create table demo
(
id bigint not null comment '主键'
primary key,
name varchar(255) null comment '姓名',
sex varchar(255) null comment '性别',
created datetime null comment '创建时间',
creator bigint null comment '创建人ID',
updated datetime not null comment '更新时间'
);
期望的输出
type Demo struct {
ID int64 `json:"id" gorm:"column:id"` // 主键
Name sql.NullString `json:"name" gorm:"column:name"` // 姓名
Sex sql.NullString `json:"sex" gorm:"column:sex"` // 性别
Created sql.NullTime `json:"created" gorm:"column:created"` // 创建时间
Creator sql.NullInt64 `json:"creator" gorm:"column:creator"` // 创建人ID
Updated time.Time `json:"updated" gorm:"column:updated"` // 更新时间
}
func (m *Demo) TableName() string {
return "demo"
}
转换一个mysql的建表语句时,包含index关键字报错
input
{
"points": [
[
"af"
]
]
}
output
type Gen struct {
}
Please be compatible with version 2020.2. Thank you.
插件本身依赖的库API和第三方库API较少,调研如何在不发包的情况下保持最新版本的兼容性。
待转换的 sql 表
create table demo
(
id bigint not null comment '主键'
primary key,
name varchar(255) null comment '姓名',
sex varchar(255) null comment '性别',
created datetime null comment '创建时间',
creator bigint null comment '创建人ID',
updated datetime null comment '更新时间',
updater bigint null comment '更新人ID',
state tinyint default 1 null comment '-1:删除,0:不可查询,1:正常',
uuid varchar(50) null comment 'uuid',
have_return int null comment '多行注释
第二行
第三行'
);
1.0.7 版本插件转换后输出
type Demo struct {
ID int64 `json:"id" gorm:"column:id"` // 主键
Name string `json:"name" gorm:"column:name"` // 姓名
Sex string `json:"sex" gorm:"column:sex"` // 性别
Created time.Time `json:"created" gorm:"column:created"` // 创建时间
Creator int64 `json:"creator" gorm:"column:creator"` // 创建人ID
Updated time.Time `json:"updated" gorm:"column:updated"` // 更新时间
Updater int64 `json:"updater" gorm:"column:updater"` // 更新人ID
State int8 `json:"state" gorm:"column:state"` // -1:删除,0:不可查询,1:正常
Uuid string `json:"uuid" gorm:"column:uuid"` // uuid
HaveReturn int `json:"have_return" gorm:"column:have_return"` // 多行注释
第二行
第三行
}
func (m *Demo) TableName() string {
return "demo"
}
注释默认使用 "//",导致换行后的注释字符串逃逸了。
插件挺方便,感谢作者。
我的IDE是Goland2020.3版本
用本地化安装该插件时,爆出如下错误:
Plugin 'Convent JSON/SQL to GO Struct' (version '1.0.0') is not compatible with the current version of the IDE, because it requires build 191.* or older but the current build is GO-203.8084.22
My input is
create Table image_file
(
image_id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
fileKey VARCHAR(1024) UNIQUE NOT NULL,
isProcessed BOOLEAN DEFAULT NOT NOT NULL,
isAssigned BOOLEAN DEFAULT FALSE NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
And the output is
type ImageFile struct {
ImageID uint `json:"image_id" gorm:"column:image_id"`
FileKey string `json:"fileKey" gorm:"column:fileKey"`
IsProcessed unknown `json:"isProcessed" gorm:"column:isProcessed"`
IsAssigned unknown `json:"isAssigned" gorm:"column:isAssigned"`
CreatedAt time.Time `json:"created_at" gorm:"column:created_at"`
}
func (m *ImageFile) TableName() string {
return "image_file"
}
I was expecting isProcessed
and isAssinged
to be bool
rather than unknown.
override fun accept(t: SQLColumnDefinition) {
// 这个判断会跳过一些字段,比如 keyword 字段
// if (t.nameAsString.toUpperCase().contains("KEY")) {
// return
// }
cols.add(t)
}
希望能提取出mysql语句中的COMMENT关键字内容,作为一个参数能够赋值到tag模板中.
比如mysql语句片段为
d1_bp DECIMAL(7,4) NOT NULL DEFAULT 0.0 COMMENT '涨跌基点数',
能提取出"涨跌基点数"作为%s2或其它通配符, 插入到tag模板中
json:"%s" stbl:"%s" desc:"%s2"
最终生成的结构体tag为
json:"d1_bp" stbl:"d1_bp" desc:"涨跌基点数"
希望增加 json和sql转换到结构体时,自动进行内存对齐操作
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.