From e8419f8b75d1c03fac5eba9079cb98706eead29a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Wed, 14 Dec 2022 10:40:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96slice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helper.go | 6 +++--- slice.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) 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 }