Consider the following example:
lock.RLock()
var product *Product
if store[productId] != nil { //cannot convert nil to type Product
product = &Product{}
*product = *store[productId] //invalid indirect of store[productId] (type Product)
}
lock.RUnlock()
The exceptions are as commented per line and i don't really get what i am doing wrong..
store
is a map[int]Product
any ideas?
You are using store
as if it were declared as:
store := make(map[int]*Product)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With