func (this State) String()string{
switch this {
case Running :
return "Running"
case Stopped :
return "Stopped"
default :
return "Unknow"
}
}
func main(){
state := Stopped
fmt.Println("state", state)
}
运行...
state Stopped
Linux公社的RSS地址:https://www.linuxidc.com/rssFeed.aspx