package main
import (
"fmt"
"unsafe"
)
type bytes []byte
//非线程安全地
func (bytes) tostring(bs []byte) string {
return *(*string)(unsafe.Pointer(&bs))
}
func main() {
s := "你好呀"
n := []byte(s)
fmt.Println(toString(n))
}
Golang中byte数组转string
发布于 2021-04-04 807 次阅读
Comments 2 条评论
How is the COVID situation over there?
@Much Photos Watch Covid is well controlled!