enumer
enumer copied to clipboard
fix: error tranforming empty name with title-lower
all of the other transforms work with an empty string, but because title-lower
tries to access rune at position 0
it throws an error
//go:generate go run github.com/dmarkham/enumer -type=Pill -transform=title-lower --linecomment
type Pill int
const (
Placebo Pill = iota //
Aspirin
Ibuprofen
Paracetamol
Acetaminophen = Paracetamol
)
Error
[Info - 4:09:00 PM] 2023/08/14 16:09:00 panic: runtime error: index out of range [0] with length 0
goroutine 1 [running]:
main.(*Generator).transformValueNames.func8({0x0?, 0x14000080480?})
/MYREPO/vendor/github.com/dmarkham/enumer/stringer.go:361 +0x84
main.(*Generator).transformValueNames(0x16f3f72df?, {0x140010bf980, 0x5, 0x1?}, {0x16f3f72fb?, 0x160?})
/MYREPO/vendor/github.com/dmarkham/enumer/stringer.go:388 +0x444
ping @dmarkham lgtm
@dmarkham any chance to get 👀 on this pr?