https://juejin.cn/post/6942005360416784397

    1. go get golang.org/x/tools/cmd/stringer

    //go:generate stringer -type ErrCode -linecomment

    1. type Pill int
    2. const (
    3. Placebo Pill = iota
    4. Aspirin
    5. Ibuprofen
    6. Paracetamol
    7. Acetaminophen = Paracetamol
    8. )
    9. //go:generate stringer -type Pill