| 1 | package util |
| 2 | |
| 3 | import ( |
| 4 | "reflect" |
| 5 | ) |
| 6 | |
| 7 | // IsUnsignedInt reports whether kind is an unsigned integer type. |
| 8 | // |
| 9 | // Parameters: |
| 10 | // - kind: The reflect.Kind to check. |
| 11 | // |
| 12 | // Returns: |
| 13 | // - true if kind is Uint, Uint8, Uint16, Uint32, or Uint64; false otherwise. |
| 14 | func IsUnsignedInt(kind reflect.Kind) bool { |
| 15 | return kind >= reflect.Uint && kind <= reflect.Uint64 |
| 16 | } |
| 17 | |
| 18 | // IsSignedInt reports whether kind is a signed integer type. |
| 19 | // |
| 20 | // Parameters: |
| 21 | // - kind: The reflect.Kind to check. |
| 22 | // |
| 23 | // Returns: |
| 24 | // - true if kind is Int, Int8, Int16, Int32, or Int64; false otherwise. |
| 25 | func IsSignedInt(kind reflect.Kind) bool { |
| 26 | return kind >= reflect.Int && kind <= reflect.Int64 |
| 27 | } |
| 28 | |
| 29 | // IsCollection reports whether kind is a slice or array type. |
| 30 | // |
| 31 | // Parameters: |
| 32 | // - kind: The reflect.Kind to check. |
| 33 | // |
| 34 | // Returns: |
| 35 | // - true if kind is Slice or Array; false otherwise. |
| 36 | func IsCollection(kind reflect.Kind) bool { |
| 37 | return kind == reflect.Slice || kind == reflect.Array |
| 38 | } |
| 39 | |
| 40 | // IsNumeric reports whether kind is a numeric type. |
| 41 | // |
| 42 | // Parameters: |
| 43 | // - kind: The reflect.Kind to check. |
| 44 | // |
| 45 | // Returns: |
| 46 | // - true if kind is any integer (signed or unsigned), float, or complex type; false otherwise. |
| 47 | func IsNumeric(kind reflect.Kind) bool { |
| 48 | return kind >= reflect.Int && kind <= reflect.Complex128 |
| 49 | } |