no copy to change slice to string use your own risk
(b []byte)
| 24 | // no copy to change slice to string |
| 25 | // use your own risk |
| 26 | func String(b []byte) (s string) { |
| 27 | pbytes := (*reflect.SliceHeader)(unsafe.Pointer(&b)) |
| 28 | pstring := (*reflect.StringHeader)(unsafe.Pointer(&s)) |
| 29 | pstring.Data = pbytes.Data |
| 30 | pstring.Len = pbytes.Len |
| 31 | return |
| 32 | } |
| 33 | |
| 34 | // no copy to change string to slice |
| 35 | // use your own risk |