-
Notifications
You must be signed in to change notification settings - Fork 322
Open
Description
I propose adding ToSliceX helper functions to the cast package for converting values into slices of numeric types (e.g. []int, []int64, []float64).
Proposed API
ToIntSlice(i interface{}) []int
ToIntSliceE(i interface{}) ([]int, error)
ToInt64Slice(i interface{}) []int64
ToFloat64Slice(i interface{}) []float64
/* other functions */These functions would convert common inputs like []interface{}, []string, or already-typed slices.
Benefits
- Reduces boilerplate
- Improves consistency with existing
castAPIs - Makes numeric slice handling simpler and safer
Contribution
I’m happy to implement this feature, including tests and documentation, if the maintainers agree with the approach.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels