Remove StringToBytes

This commit is contained in:
Vladimir Mihailenco 2018-01-15 16:15:20 +02:00
parent 041b11eb4f
commit abb85b0fb8
3 changed files with 3 additions and 16 deletions

View File

@ -123,8 +123,9 @@ func ScanSlice(data []string, slice interface{}) error {
next := internal.MakeSliceNextElemFunc(v) next := internal.MakeSliceNextElemFunc(v)
for i, s := range data { for i, s := range data {
elem := next() elem := next()
if err := Scan(internal.StringToBytes(s), elem.Addr().Interface()); err != nil { if err := Scan([]byte(s), elem.Addr().Interface()); err != nil {
return fmt.Errorf("redis: ScanSlice(index=%d value=%q) failed: %s", i, s, err) err = fmt.Errorf("redis: ScanSlice index=%d value=%q failed: %s", i, s, err)
return err
} }
} }

View File

@ -5,7 +5,3 @@ package internal
func BytesToString(b []byte) string { func BytesToString(b []byte) string {
return string(b) return string(b)
} }
func StringToBytes(s string) []byte {
return []byte(s)
}

View File

@ -10,13 +10,3 @@ import (
func BytesToString(b []byte) string { func BytesToString(b []byte) string {
return *(*string)(unsafe.Pointer(&b)) return *(*string)(unsafe.Pointer(&b))
} }
// StringToBytes converts string to byte slice.
func StringToBytes(s string) []byte {
return *(*[]byte)(unsafe.Pointer(
&struct {
string
Cap int
}{s,len(s)},
))
}