Closed amlwwalker closed 4 years ago
In general, direct casting like following code is not possible:
value, ok := data.(<something>)
Still, it would be possible to store data like []byte{} into database, if those bytes reflect result of json.Marshal method- in that case, json.Unmarshal back to instance of dynamic struct would be possible, as a way of casting :)
err := json.Unmarshal(data, &value)
I am creating a dynamic struct and storing the definition (
[]byte{}
data) to a database.I have an
interface{}
which I need to cast back to the dynamic type, once I load it out of the database. Is this possible?