MCPcopy
hub / github.com/gin-gonic/gin / decodePlain

Function decodePlain

binding/plain.go:31–56  ·  view source on GitHub ↗
(data []byte, obj any)

Source from the content-addressed store, hash-verified

29}
30
31func 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}

Callers 2

BindMethod · 0.85
BindBodyMethod · 0.85

Calls 1

BytesToStringFunction · 0.92

Tested by

no test coverage detected