实例
type MongoStatusEnum string const ( Success MongoStatusEnum = "success" Fail MongoStatusEnum = "fail" Start MongoStatusEnum = "start" ) func Get(m MongoStatusEnum) string { return gconv.String(m) }
延伸
package main import "fmt" func main() { zz := 1 ss := GetBannerTypeDescription(BannerType(zz)) fmt.Println(ss) } // BannerType 传输协议 type BannerType int const ( BannerTypeInAppStart BannerType = 1 // 开屏页 BannerTypeAD BannerType = 2 // 广告页 ) func GetBannerTypeDescription(b BannerType) string { if b == BannerTypeInAppStart { return "开屏页" } else if b == BannerTypeAD { return "广告页" } return "" }