Removal of integer flags causes issues. #2050
Labels
area/v3
relates to / is being considered for v3
status/triage
maintainers still need to look into this
status/waiting-for-response
Waiting for response from original requester
Checklist
What problem does this solve?
The new opinionated
IntFlag
does not document on how to work with other types thanint64
. If I have a struct which I want to configure using flags, I do not want to restrict myself to usingint64
since the struct is not defined by my project. I also do not want to create custom flags for builtin types.I've tried to use the
Action
function on the flag to set the value for a field of typeint
but it doesn't work with default values, making any workaround too convoluted.The issue of
intValue
not being exported cause issues if I want to do any form of customization of the flag and this applies to all other flag types. Allowing reuse in custom flags would be nice.Solution description
Use generics to implement
IntFlag
,Int8Flag
,Int16Flag
,Int32Flag
andInt64Flag
.Describe alternatives you've considered
One way would be to recreate the types that you removed but use generics to avoid code duplication.
All methods use pointer receivers as recommended by the Go documentation. https://go.dev/doc/faq#methods_on_values_or_pointers
Making all the receivers either values or pointers avoids mistakes. Linters and IDEs will pick up on this and warn you about mixing values and pointers.
I can contribute a solution based on this if so desired.
The text was updated successfully, but these errors were encountered: