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

39 lines
722 B
Go

package entity
type Gender uint
const (
MaleGender Gender = iota + 1
FemaleGender
)
var GenderStrings = map[Gender]string{
MaleGender: "male",
FemaleGender: "female",
}
func (s Gender) String() string {
return GenderStrings[s]
}
// AllGender returns a slice containing all string values of Gender.
func AllGender() []string {
statusStrings := make([]string, len(GenderStrings))
for status, str := range GenderStrings {
statusStrings[int(status)-1] = str
}
return statusStrings
}
// MapToGender converts a string to the corresponding Gender value.
func MapToGender(statusStr string) Gender {
for status, str := range GenderStrings {
if str == statusStr {
return status
}
}
return Gender(0)
}