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

Function AppendArg

internal/arg.go:11–53  ·  view source on GitHub ↗
(b []byte, v interface{})

Source from the content-addressed store, hash-verified

9)
10
11func AppendArg(b []byte, v interface{}) []byte {
12 switch v := v.(type) {
13 case nil:
14 return append(b, "<nil>"...)
15 case string:
16 return appendUTF8String(b, util.StringToBytes(v))
17 case []byte:
18 return appendUTF8String(b, v)
19 case int:
20 return strconv.AppendInt(b, int64(v), 10)
21 case int8:
22 return strconv.AppendInt(b, int64(v), 10)
23 case int16:
24 return strconv.AppendInt(b, int64(v), 10)
25 case int32:
26 return strconv.AppendInt(b, int64(v), 10)
27 case int64:
28 return strconv.AppendInt(b, v, 10)
29 case uint:
30 return strconv.AppendUint(b, uint64(v), 10)
31 case uint8:
32 return strconv.AppendUint(b, uint64(v), 10)
33 case uint16:
34 return strconv.AppendUint(b, uint64(v), 10)
35 case uint32:
36 return strconv.AppendUint(b, uint64(v), 10)
37 case uint64:
38 return strconv.AppendUint(b, v, 10)
39 case float32:
40 return strconv.AppendFloat(b, float64(v), 'f', -1, 64)
41 case float64:
42 return strconv.AppendFloat(b, v, 'f', -1, 64)
43 case bool:
44 if v {
45 return append(b, "true"...)
46 }
47 return append(b, "false"...)
48 case time.Time:
49 return v.AppendFormat(b, time.RFC3339Nano)
50 default:
51 return append(b, fmt.Sprint(v)...)
52 }
53}
54
55func appendUTF8String(dst []byte, src []byte) []byte {
56 dst = append(dst, src...)

Callers 1

cmdStringFunction · 0.92

Calls 2

StringToBytesFunction · 0.92
appendUTF8StringFunction · 0.70

Tested by

no test coverage detected