go没有枚举类型,可以通过iota来定义枚举值。
package main import "fmt" type Status int const ( Unknown Status = iota Success Fail ) func main() { // 输出1 fmt.Println(Success) }
posted on 2026-04-05 09:11 王景迁 阅读(7) 评论(0) 收藏 举报
博客园 © 2004-2026 浙公网安备 33010602011771号 浙ICP备2021040463号-3