iota で Stringer な Enum はこんな感じだろうか。
package main
import (
"log"
)
func init() {
log.SetFlags(log.Lshortfile)
}
type Indexing int
func (i Indexing) String() string {
switch i {
case WITH:
return "WITH"
case WITHOUT:
return "WITHOUT"
case NEVER:
return "NEVER"
}
log.Fatal("can't be here")
return ""
}
const (
WITH Indexing = iota
WITHOUT
NEVER
)
func main() {
log.Println(WITH, WITHOUT, NEVER)
}