diff options
Diffstat (limited to 'vendor/github.com/go-redis/redis/internal/util/unsafe.go')
-rw-r--r-- | vendor/github.com/go-redis/redis/internal/util/unsafe.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/vendor/github.com/go-redis/redis/internal/util/unsafe.go b/vendor/github.com/go-redis/redis/internal/util/unsafe.go new file mode 100644 index 0000000000..c9868aac2b --- /dev/null +++ b/vendor/github.com/go-redis/redis/internal/util/unsafe.go @@ -0,0 +1,22 @@ +// +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)}, + )) +} |