Skip to content

Update or replace the enumer go:generate tool #2998

@na--

Description

@na--

Currently, we are using https://github.com/alvaroloes/enumer to semi-automatically generate some helper methods for a several enum types we have in k6:

go install github.com/alvaroloes/[email protected]

k6/metrics/system_tag.go

Lines 12 to 13 in c09919b

//go:generate enumer -type=SystemTag -transform=snake -trimprefix=Tag -output system_tag_gen.go
type SystemTag uint32

k6/lib/execution.go

Lines 34 to 35 in c09919b

//go:generate enumer -type=ExecutionStatus -trimprefix ExecutionStatus -output execution_status_gen.go
type ExecutionStatus uint32

(and others)

Unfortunately, it hasn't been updated since 2019, and the current version produces code that has linter errors. It's also produces some methods we don't really use in all types...

The active fork of that tool seems to be https://github.com/dmarkham/enumer, and it fixes some things. Unfortunately, it also makes the second problem even worse. For example, it adds lowercase support (dmarkham/enumer#22) in a way that can't be disabled (dmarkham/enumer#40), which is not something we necessarily want in all of our types... 😞

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions