enumer icon indicating copy to clipboard operation
enumer copied to clipboard

fix: error tranforming empty name with title-lower

Open jazanne opened this issue 10 months ago • 2 comments

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

jazanne avatar Aug 14 '23 20:08 jazanne

ping @dmarkham lgtm

andig avatar Feb 20 '24 08:02 andig

@dmarkham any chance to get 👀 on this pr?

jazanne avatar Apr 30 '24 18:04 jazanne