(data []byte, obj any)
| 29 | } |
| 30 | |
| 31 | func decodePlain(data []byte, obj any) error { |
| 32 | if obj == nil { |
| 33 | return nil |
| 34 | } |
| 35 | |
| 36 | v := reflect.ValueOf(obj) |
| 37 | |
| 38 | for v.Kind() == reflect.Ptr { |
| 39 | if v.IsNil() { |
| 40 | return nil |
| 41 | } |
| 42 | v = v.Elem() |
| 43 | } |
| 44 | |
| 45 | if v.Kind() == reflect.String { |
| 46 | v.SetString(bytesconv.BytesToString(data)) |
| 47 | return nil |
| 48 | } |
| 49 | |
| 50 | if _, ok := v.Interface().([]byte); ok { |
| 51 | v.SetBytes(data) |
| 52 | return nil |
| 53 | } |
| 54 | |
| 55 | return fmt.Errorf("type (%T) unknown type", v) |
| 56 | } |
no test coverage detected