...

Source file src/github.com/go-redis/redis/internal/util/unsafe.go

Documentation: github.com/go-redis/redis/internal/util

     1  // +build !appengine
     2  
     3  package util
     4  
     5  import (
     6  	"unsafe"
     7  )
     8  
     9  // BytesToString converts byte slice to string.
    10  func BytesToString(b []byte) string {
    11  	return *(*string)(unsafe.Pointer(&b))
    12  }
    13  
    14  // StringToBytes converts string to byte slice.
    15  func StringToBytes(s string) []byte {
    16  	return *(*[]byte)(unsafe.Pointer(
    17  		&struct {
    18  			string
    19  			Cap int
    20  		}{s, len(s)},
    21  	))
    22  }
    23  

View as plain text