go-chat/user/user.go
2021-04-28 16:16:18 +08:00

27 lines
411 B
Go

package user
import (
"errors"
"fmt"
)
const Key = "go_chat_Users:%d"
type User struct {
Id int `json:"id"`
Name string `json:"name"`
Sex int8 `json:"sex"`
Password string `json:"password"`
}
func GetUserKey(id int) string {
return fmt.Sprintf(Key, id)
}
func (u *User) CheckPassword(p string) error {
if p != u.Password {
return errors.New("password error")
}
return nil
}