Skip to content

Commit

Permalink
chore: linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ikadix committed Jul 3, 2024
1 parent d2b3b98 commit 2b83aa4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions next/deref.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import "reflect"
func DerefOrEmpty[T any](in *T) T {
if in == nil {
tType := reflect.TypeOf(*new(T))

//nolint:exhaustive
switch tType.Kind() {
case reflect.Slice, reflect.Array:
return reflect.MakeSlice(tType, 0, 0).Interface().(T)
case reflect.Map:
return reflect.MakeMap(tType).Interface().(T)
default:
var empty T

return empty
}
}
Expand Down

0 comments on commit 2b83aa4

Please sign in to comment.