diff options
Diffstat (limited to 'go/utils')
| -rw-r--r-- | go/utils/slices.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/go/utils/slices.go b/go/utils/slices.go index d2bc04c1..3cc38c1c 100644 --- a/go/utils/slices.go +++ b/go/utils/slices.go @@ -7,3 +7,11 @@ func TypedSliceToInterfaceSlice[T any](s []T) []interface{} { } return is } + +func InterfaceSliceToTypedSlice[T any](s []interface{}) []T { + ts := make([]T, 0, len(s)) + for _, t := range s { + ts = append(ts, t.(T)) + } + return ts +} |
