package internal
import (
"fmt"
"strconv"
"time"
"github.com/redis/go-redis/v9/internal/util"
)
func AppendArg (b []byte , v interface {}) []byte {
switch v := v .(type ) {
case nil :
return append (b , "<nil>" ...)
case string :
return appendUTF8String (b , util .StringToBytes (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
}
The pages are generated with Golds v0.8.2 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .