mirror of
https://github.com/go-gitea/gitea
synced 2024-12-24 03:36:02 +01:00
ac97ea573c
* Update go-redis to v8.4.0 * github.com/go-redis/redis/v8 v8.4.0 -> v8.5.0 * Apply suggestions from code review Co-authored-by: zeripath <art27@cantab.net> * TODO * Use the Queue termination channel as the default context for pushes Signed-off-by: Andrew Thornton <art27@cantab.net> * missed one Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: zeripath <art27@cantab.net>
57 lines
1.2 KiB
Go
Vendored
57 lines
1.2 KiB
Go
Vendored
package internal
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
"time"
|
|
)
|
|
|
|
func AppendArg(b []byte, v interface{}) []byte {
|
|
switch v := v.(type) {
|
|
case nil:
|
|
return append(b, "<nil>"...)
|
|
case string:
|
|
return appendUTF8String(b, Bytes(v))
|
|
case []byte:
|
|
return appendUTF8String(b, v)
|
|
case int:
|
|
return strconv.AppendInt(b, int64(v), 10)
|
|
case int8:
|
|
return strconv.AppendInt(b, int64(v), 10)
|
|
case int16:
|
|
return strconv.AppendInt(b, int64(v), 10)
|
|
case int32:
|
|
return strconv.AppendInt(b, int64(v), 10)
|
|
case int64:
|
|
return strconv.AppendInt(b, v, 10)
|
|
case uint:
|
|
return strconv.AppendUint(b, uint64(v), 10)
|
|
case uint8:
|
|
return strconv.AppendUint(b, uint64(v), 10)
|
|
case uint16:
|
|
return strconv.AppendUint(b, uint64(v), 10)
|
|
case uint32:
|
|
return strconv.AppendUint(b, uint64(v), 10)
|
|
case uint64:
|
|
return strconv.AppendUint(b, v, 10)
|
|
case float32:
|
|
return strconv.AppendFloat(b, float64(v), 'f', -1, 64)
|
|
case float64:
|
|
return strconv.AppendFloat(b, v, 'f', -1, 64)
|
|
case bool:
|
|
if v {
|
|
return append(b, "true"...)
|
|
}
|
|
return append(b, "false"...)
|
|
case time.Time:
|
|
return v.AppendFormat(b, time.RFC3339Nano)
|
|
default:
|
|
return append(b, fmt.Sprint(v)...)
|
|
}
|
|
}
|
|
|
|
func appendUTF8String(dst []byte, src []byte) []byte {
|
|
dst = append(dst, src...)
|
|
return dst
|
|
}
|