mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 02:15:34 +00:00
internal/unsafe: get rid of GoString
The only users were GOOS=windows code, which can use golang.org/x/sys/windows.BytePtrToString instead. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -44,14 +44,3 @@ func SliceOf(s uintptr) []byte {
|
||||
h.Len = 1 << 30
|
||||
return res
|
||||
}
|
||||
|
||||
// GoString convert a NUL-terminated C string
|
||||
// to a Go string.
|
||||
func GoString(s []byte) string {
|
||||
for i, v := range s {
|
||||
if v == 0 {
|
||||
return string(s[:i])
|
||||
}
|
||||
}
|
||||
return string(s)
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
package unsafe
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGoString(t *testing.T) {
|
||||
tests := [][2]string{
|
||||
{"Hello\x00", "Hello"},
|
||||
{"\x00", ""},
|
||||
}
|
||||
for _, test := range tests {
|
||||
got := GoString([]byte(test[0]))
|
||||
if exp := test[1]; exp != got {
|
||||
t.Errorf("expected %q got %q", exp, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user