go语言的性别枚举封装

//性别枚举
 type Gander int

func (g Gander)String() string{
	return []string{"Male","Female","Bisexual"}[g]
}
const (
	//男的
	Male = iota
	//女的
	Female
	//二椅子
	Bisexual
)
 
 type Human struct {
 	Name string
 	Age int
 	Height int
 	Weight int
 	Looking int
 	Rmb int
 	//自己的性别
 	Sex Gander
 	//结婚对象的性别
 	TargetSex Gander
 }

func main() {
	
}

 

你可能感兴趣的:(go语言)