6

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?

1 Answer 1

6

You are using store as if it were declared as:

store := make(map[int]*Product)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.