diff --git a/helper.go b/helper.go index f7590dc..f60e822 100644 --- a/helper.go +++ b/helper.go @@ -13,8 +13,8 @@ func BytesToString(b []byte) string { func StringToBytes(s string) (b []byte) { bh := (*slice)(unsafe.Pointer(&b)) sh := (*slice)(unsafe.Pointer(&s)) - bh.Data = sh.Data - bh.Len = sh.Len - bh.Cap = sh.Len + bh.data = sh.data + bh.len = sh.len + bh.cap = sh.len return b } diff --git a/slice.go b/slice.go index b133217..cf66464 100644 --- a/slice.go +++ b/slice.go @@ -9,7 +9,7 @@ import "unsafe" // Unlike reflect.SliceHeader, its Data field is sufficient to guarantee the // data it references will not be garbage collected. type slice struct { - Data unsafe.Pointer - Len int - Cap int + data unsafe.Pointer + len int + cap int }