You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
337 B
20 lines
337 B
package unsafebytes |
|
|
|
import "unsafe" |
|
|
|
func Pointer(b []byte) *byte { |
|
return *(**byte)(unsafe.Pointer(&b)) |
|
} |
|
|
|
func String(b []byte) string { |
|
return *(*string)(unsafe.Pointer(&b)) |
|
} |
|
|
|
func BytesOf(s string) []byte { |
|
return *(*[]byte)(unsafe.Pointer(&sliceHeader{str: s, cap: len(s)})) |
|
} |
|
|
|
type sliceHeader struct { |
|
str string |
|
cap int |
|
}
|
|
|