1 Star 0 Fork 0

邢楠 / toolbox

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
unsafe.go 362 Bytes
一键复制 编辑 原始数据 按行查看 历史
邢楠 提交于 2020-10-28 09:39 . # 124
// +build !appengine
package util
import (
"unsafe"
)
// BytesToString converts byte slice to string.
func BytesToString(b []byte) string {
return *(*string)(unsafe.Pointer(&b))
}
// StringToBytes converts string to byte slice.
func StringToBytes(s string) []byte {
return *(*[]byte)(unsafe.Pointer(
&struct {
string
Cap int
}{s, len(s)},
))
}
Go
1
https://gitee.com/xingnan/toolbox.git
git@gitee.com:xingnan/toolbox.git
xingnan
toolbox
toolbox
b7d4d010dbc3

搜索帮助