MCPcopy
hub / github.com/redis/go-redis / appendArg

Function appendArg

commands.go:67–108  ·  view source on GitHub ↗
(dst []interface{}, arg interface{})

Source from the content-addressed store, hash-verified

65}
66
67func appendArg(dst []interface{}, arg interface{}) []interface{} {
68 switch arg := arg.(type) {
69 case []string:
70 for _, s := range arg {
71 dst = append(dst, s)
72 }
73 return dst
74 case []interface{}:
75 dst = append(dst, arg...)
76 return dst
77 case map[string]interface{}:
78 for k, v := range arg {
79 dst = append(dst, k, v)
80 }
81 return dst
82 case map[string]string:
83 for k, v := range arg {
84 dst = append(dst, k, v)
85 }
86 return dst
87 case time.Time, time.Duration, encoding.BinaryMarshaler, net.IP:
88 return append(dst, arg)
89 case nil:
90 return dst
91 default:
92 // scan struct field
93 v := reflect.ValueOf(arg)
94 if v.Type().Kind() == reflect.Ptr {
95 if v.IsNil() {
96 // error: arg is not a valid object
97 return dst
98 }
99 v = v.Elem()
100 }
101
102 if v.Type().Kind() == reflect.Struct {
103 return appendStructField(dst, v)
104 }
105
106 return append(dst, arg)
107 }
108}
109
110// appendStructField appends the field and value held by the structure v to dst, and returns the appended dst.
111func appendStructField(dst []interface{}, v reflect.Value) []interface{} {

Callers 2

appendArgsFunction · 0.70
XAddMethod · 0.70

Calls 2

appendStructFieldFunction · 0.85
TypeMethod · 0.65

Tested by

no test coverage detected