forked from ebhomengo/niki
1
0
Fork 0
niki/entity/user_gender.go

39 lines
806 B
Go
Raw Normal View History

2024-01-02 15:35:26 +00:00
package entity
type UserGender uint
const (
UserMaleGender UserGender = iota + 1
UserFemaleGender
)
var UserGenderStrings = map[UserGender]string{
UserMaleGender: "male",
UserFemaleGender: "female",
}
func (s UserGender) String() string {
return UserGenderStrings[s]
}
// AllUserGender returns a slice containing all string values of UserGender.
func AllUserGender() []string {
statusStrings := make([]string, len(UserGenderStrings))
for status, str := range UserGenderStrings {
statusStrings[int(status)-1] = str
}
return statusStrings
}
// MapToUserGender converts a string to the corresponding UserGender value.
func MapToUserGender(statusStr string) UserGender {
for status, str := range UserGenderStrings {
if str == statusStr {
return status
}
}
return UserGender(0)
}