问题
通过gorm建mysql表,发生错误,错误信息如下
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 ')' at line 1
结构体定义
type testTable struct{
testCol1 int
testCol2 int
testCol3 int
}
原因
golang中首字母小写表示package私有,通过gorm操作时无法访问私有成员
解决方案
如下修改结构体定义
type TestTable struct{
TestCol1 int
TestCol2 int
TestCol3 int
}