I have this code:
type TestData struct {
Key string
}
type TemporaryStoreItem struct {
key string
data interface{}
aliveUntil time.Time
}
func (s *TemporaryStoreItem) SetData(src interface{}) {
src = s.data
}
data := TestData{
Key: "value",
}
item := TemporaryStoreItem{
key: "item1",
data: data,
aliveUntil: time.Now(),
}
oldItem := TestData{}
item.SetData(&oldItem)
I need to save any data or pointer to data in 'data' field of TemporaryStoreItem, and i need to get data as TestData struct(or any else source struct), what i do wrong, and is it possible to implement this idea?