Helper function to check if a value is null/nil
(v reflect.Value)
| 105 | |
| 106 | // Helper function to check if a value is null/nil |
| 107 | func isNull(v reflect.Value) bool { |
| 108 | // Zero value (Invalid kind) is considered null |
| 109 | if !v.IsValid() { |
| 110 | return true |
| 111 | } |
| 112 | switch v.Kind() { |
| 113 | case reflect.Ptr, reflect.Interface, reflect.Slice, reflect.Map, reflect.Func: |
| 114 | return v.IsNil() // Check if reference types are nil |
| 115 | default: |
| 116 | return false // Value types are never null |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | // sliceSerializer serialize a slice whose elem is not an interface or pointer to interface. |
| 121 | // Use newSliceSerializer to create instances with proper type validation. |
no test coverage detected