When writing data to a redis hash in go, I ran into the problem that a struct array could not be written. I looked into it and the data to be written is required to be map[string]interface, while mine was a struct. Therefore, it could not be written.
So it’s just a matter of converting the format.
type order struct{
Id int64 `json:"id"`
orderSn int64 `json:"order_sn"`
}
orders:=order{
Id:2022032034566
OrderSn:20220320122444
}
jsonData,_:=json.Marshal(orders)
var redisData map[string]interface{}
json.Unmarshal([]byte(jsonData),&redisData)
log.Info(redisData)
The above is the conversion process.

