func StrToBytes(s string) []byte { x := (*[2]uintptr)(unsafe.Pointer(&s)) b := [3]uintptr{x[0], x[1], x[1]} return *(*[]byte)(unsafe.Pointer(&b)) } func BytesToStr(b []byte) string { return *(*string)(unsafe.Pointer(&b)) }
原文:https://www.cnblogs.com/wangjq19920210/p/14362202.html