From: Tobias Klauser Date: Wed, 7 Sep 2022 12:07:12 +0000 (+0200) Subject: os: use unsafe.{Slice,StringData} instead of unsafeheader package X-Git-Tag: go1.20rc1~1100 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d75e91740a2048bba4c70e878a4cd3551e7b2273;p=gostls13.git os: use unsafe.{Slice,StringData} instead of unsafeheader package Change-Id: I213b078effa4b7049c44498d651de5b938e5404b Reviewed-on: https://go-review.googlesource.com/c/go/+/428779 TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor Reviewed-by: Michael Knyszek Run-TryBot: Tobias Klauser Reviewed-by: hopehook Run-TryBot: hopehook Auto-Submit: Tobias Klauser --- diff --git a/src/os/file.go b/src/os/file.go index 9f388921ae..e2eef8ec5d 100644 --- a/src/os/file.go +++ b/src/os/file.go @@ -43,7 +43,6 @@ import ( "errors" "internal/poll" "internal/testlog" - "internal/unsafeheader" "io" "io/fs" "runtime" @@ -247,11 +246,7 @@ func (f *File) Seek(offset int64, whence int) (ret int64, err error) { // WriteString is like Write, but writes the contents of string s rather than // a slice of bytes. func (f *File) WriteString(s string) (n int, err error) { - var b []byte - hdr := (*unsafeheader.Slice)(unsafe.Pointer(&b)) - hdr.Data = (*unsafeheader.String)(unsafe.Pointer(&s)).Data - hdr.Cap = len(s) - hdr.Len = len(s) + b := unsafe.Slice(unsafe.StringData(s), len(s)) return f.Write(b) }