From 87db552b00fd1d5e9f6b1d3a845e5d711b98f7e2 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 6 Sep 2022 11:03:01 +0200 Subject: [PATCH] plan9: use unsafe.Slice instead of unsafeheader package Go 1.18 is the minimum supported Go version and unsafe.Slice was introduced in Go 1.17. Change-Id: I696dba9b932c522688ee55fdef43d8776f8afbe1 Reviewed-on: https://go-review.googlesource.com/c/sys/+/428516 Reviewed-by: Benny Siegert Run-TryBot: Tobias Klauser TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor --- plan9/syscall.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/plan9/syscall.go b/plan9/syscall.go index a25223b8..ea971285 100644 --- a/plan9/syscall.go +++ b/plan9/syscall.go @@ -29,8 +29,6 @@ import ( "bytes" "strings" "unsafe" - - "golang.org/x/sys/internal/unsafeheader" ) // ByteSliceFromString returns a NUL-terminated slice of bytes @@ -82,12 +80,7 @@ func BytePtrToString(p *byte) string { ptr = unsafe.Pointer(uintptr(ptr) + 1) } - var s []byte - h := (*unsafeheader.Slice)(unsafe.Pointer(&s)) - h.Data = unsafe.Pointer(p) - h.Len = n - h.Cap = n - + s := unsafe.Slice((*byte)(unsafe.Pointer(p)), n) return string(s) }