Reputation: 3865
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?
Upvotes: 6
Views: 6431
Reputation: 166714
You are using store
as if it were declared as:
store := make(map[int]*Product)
Upvotes: 6