顺便说一句,使用金珠的GORM软件包,我目前有以下 struct :
type User struct {
gorm.Model
// The Users username
Username string `gorm:"size:255;unique;not null"`
// The Users email address
Email string `gorm:"size:255;unique;not null"`
// The Users hashed password
Password string `gorm:"size:255;not null"`
// The Users password confirmation (only for forms)
PasswordC string `gorm:"-"`
// The Users FULL NAME (e.g. Burt Reynolds)
Fullname string `gorm:"size:255; not null"`
// The Users Karma level
Karma int
// Is the user banned?
Banned bool
}
但是我也使用了Gorilla的Schema
包,所以任何表单值都会填充到 struct 中,但是我不希望将PasswordC
保存到数据库中,因为它将是纯文本,因为普通的Password
字段会被bcrypt,所以关于如何使GORM
不保存PasswordC
字段的任何信息.