I am trying to make a for loop that will convert any data type to a byte array... this is what I have right now
var arrByte [][]byte
for _,v := range *arr.(*[]interface{}) {
string := fmt.Sprint(v) // What can I put here so that I dont have to convert to string
arrByte = append(arrByte, []byte(string))
}
The problem with this code is that I cant convert it back to its data types. So how can I directly change it so that It keeps the formatting correct so then I can later run this?
var arrInterface []interface{}
for _,v := range arrByte {
data := binary.BigEndian.Uint64(v)
arrInterface = append(arrInterface, data)
}