I would like to define types of sync.Map so that I can have some type checking and basically isolate the interface{} use. Is it safe to use sync.Map like this ?
type WalletMap sync.Map
var walletMap = &WalletMap{}
func (m *WalletMap) LoadOrStore(key string, value *CoinMap) (actual *CoinMap, loaded bool) {
itf, ok := (*sync.Map)(m).LoadOrStore(key, value)
if !ok {
return nil, ok
}
return itf.(*CoinMap), ok
}
func (m *WalletMap) Load(key string) (actual *CoinMap, loaded bool) {
itf, ok := (*sync.Map)(m).Load(key)
if !ok {
return nil, ok
}
return itf.(*CoinMap), ok
}