package user import ( "golang.org/x/crypto/bcrypt" ) type User struct { Id *int64 `json:"id"` Username *string `json:"username"` PasswordHash *string `json:"password_hash"` Password *string `json:"password"` // Only used in update. } func New(id int64, username string, password_hash string) User { return User{ Id: &id, Username: &username, PasswordHash: &password_hash, } } func (self User) CheckPassword(password string) bool { err := bcrypt.CompareHashAndPassword([]byte(*(self.PasswordHash)), []byte(password)) return err == nil }