diff --git a/command.go b/command.go index 319bfba2..cb1f26a3 100644 --- a/command.go +++ b/command.go @@ -104,7 +104,7 @@ func cmdString(cmd Cmder, val interface{}) string { b = internal.AppendArg(b, val) } - return internal.String(b) + return util.BytesToString(b) } //------------------------------------------------------------------------------ diff --git a/internal/arg.go b/internal/arg.go index b97fa0d6..af5f8c93 100644 --- a/internal/arg.go +++ b/internal/arg.go @@ -4,6 +4,8 @@ import ( "fmt" "strconv" "time" + + "github.com/go-redis/redis/v9/internal/util" ) func AppendArg(b []byte, v interface{}) []byte { @@ -11,7 +13,7 @@ func AppendArg(b []byte, v interface{}) []byte { case nil: return append(b, ""...) case string: - return appendUTF8String(b, Bytes(v)) + return appendUTF8String(b, util.StringToBytes(v)) case []byte: return appendUTF8String(b, v) case int: diff --git a/internal/safe.go b/internal/safe.go deleted file mode 100644 index fd2f4340..00000000 --- a/internal/safe.go +++ /dev/null @@ -1,12 +0,0 @@ -//go:build appengine -// +build appengine - -package internal - -func String(b []byte) string { - return string(b) -} - -func Bytes(s string) []byte { - return []byte(s) -} diff --git a/internal/unsafe.go b/internal/unsafe.go deleted file mode 100644 index 9f2e418f..00000000 --- a/internal/unsafe.go +++ /dev/null @@ -1,21 +0,0 @@ -//go:build !appengine -// +build !appengine - -package internal - -import "unsafe" - -// String converts byte slice to string. -func String(b []byte) string { - return *(*string)(unsafe.Pointer(&b)) -} - -// Bytes converts string to byte slice. -func Bytes(s string) []byte { - return *(*[]byte)(unsafe.Pointer( - &struct { - string - Cap int - }{s, len(s)}, - )) -}