Question: I am writing an array of float32 numbers from a Python script to an Elasticache Redis cluster in bytes format, then reading the bytes (as a string) from Elasticache in a Go script. How do I convert the bytes-as-string back to the original float32 array in the Go script? Python example: import numpy as np import redis a = np.array([1.1, 2.2, 3.3], dtype=np.float32) a_bytes = a.tobytes(order="C") #I have also tried order="F" with no luck print(a_bytes) #Output: b'\xcd\xcc\x8c?\xcd\xcc\x0c@33S@' redis_client = redis.cluster.RedisCluster(host=<elasticache config endpoint>, port=6379) redis_client.mset_nonatomic({"key1": a_bytes})  Here's an example of what I've tried in Go (playground) package main import ( "fmt" "math" "strconv" ) func main() { // aBytesStr is an example value retrieved from Elasticache // aBytesStr is type string, not raw bytes var aBytesStr string = "\xcd\xcc\x8c?\xcd\xcc\x0c@33S@" aHex := fmt.Sprintf("%X", aBytesStr) fmt.Println(aHex) // Output: CDCC8C3FCDCC0C4033335340 var aArr [3]float32 for i := 0; i < 3; i++ { aHex1 := aHex[i*8 : i*8+8] aParsed, err := strconv.ParseUint(aHex1, 16, 32) if err != nil { return } aArr[i] = math.Float32frombits(uint32(aParsed)) } fmt.Println(aArr) // Expected output: [1.1 2.2 3.3] // Actual output [-4.289679e+08 -4.2791936e+08 4.17524e-08] } 

Answer: The example code you are using is to "convert hex, represented as strings"; you have the raw bytes (I think based on aHex: CDCC8C3FCDCC0C4033335340) so its simpler to convert directly (while you could convert the bytes to a hex string, and then convert that, doing so just adds unnecessary work/complexity). Drawing from this answer we get (playground): func GetFloatArray(aBytes []byte) []float32 { aArr := make([]float32, 3) for i := 0; i < 3; i++ { aArr[i] = BytesFloat32(aBytes[i*4:]) } return aArr } func BytesFloat32(bytes []byte) float32 { bits := binary.LittleEndian.Uint32(bytes) float := math.Float32frombits(bits) return float }  Update ref comment:  I convert the bytes-as-string to a hex string, to a []bytes, to []float32. Is there a way to directly convert the bytes-as-string to []bytes?  I'm still a bit confused about what you are receiving so lets work through both possibilities. If the redis query is returning raw data (bytes) as a go string (i.e. "\xcd\xcc\x8c?\xcd\xcc\x0c@33S@") then you can just convert this to []byte (playground) func main() { var aBytesStr string = "\xcd\xcc\x8c?\xcd\xcc\x0c@33S@" fmt.Println(GetFloatArray([]byte(aBytesStr))) }  If redis is returning a string containing an ASCII (/UTF-8) representation (i.e. CDCC = []byte{0x41, 0x44, 0x43, 0x43}) the simplest approach is probably to use encoding/hex to decode this (playground) func main() { aHex := "CDCC8C3FCDCC0C4033335340" b, err := hex.DecodeString(aHex) if err != nil { panic(err) } fmt.Println(GetFloatArray(b)) }  Note that your original approach could work but, as pointed out in the comments above, you need to deal with Endianness so the following will work (playground - you could make this more efficient, I aimed for clarity): byte1 := aHex[i*8 : i*8+2] byte2 := aHex[i*8+2 : i*8+4] byte3 := aHex[i*8+4 : i*8+6] byte4 := aHex[i*8+6 : i*8+8] aParsed, err := strconv.ParseUint(byte4+byte3+byte2+byte1, 16, 32)  However this makes assumptions about the CPU the code is running on which means the previous answer is preferable.