What's the best way to implement enums in golang so you can't pass an invalid value?

后端 未结 0 924
感动是毒
感动是毒 2020-12-20 17:27

Go doesn\'t have an out-of-the-box enum type and recommends using an iota with constants as follows:

const (
    Cat byte = iota
    Dog
    Elep         


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题