Error 1292: Incorrect datetime value: '0000-00-00' for column 'created_at' at row 1
<a href="/user/18393910396" title="@18393910396">@18393910396</a>
我先是将request body Decode到结构体 `RegisterBody`中
```go
type RegisterBody struct {
UserName string `name:"username" valid:"stringlength(15|20),required"`
Password string `name:"password" valid:"stringlength(15|20),required"`
Phone string `name:"phone" valid:"numeric,length(11|11),required"`
}
```
然后用`govalidator`验证结构体正确之后就 插入数据库,但是`gorm`好像没有自动生成当前时间,然后一直报错
```
Error 1292: Incorrect datetime value: '0000-00-00' for column 'created_at' at row 1
```
#4
更多评论
```go
type User struct {
gorm.Model
Username string `gorm:"type:varchar(20);unique_index"`
Password string `gorm:"type:varchar(64)"`
Phone string `gorm:"type:char(11);unique_index"`
}
```
#2