Add instructions to use context.WithCancel() to documentation
Baggerone opened this issue · 1 comments
Baggerone commented
Maybe we just had a strange way of using your library (with gobuffalo).
When we tried to call cache.Get(), we ended up getting a panic (invalid memory address or nil pointer dereference
)
down in pool.(*ConnPool).waitTurn line 273
Apparently the context we were using and passing in to cache.Get() didn't have a proper Done() method.
Changing our code to have something like this and sending in that context seemed to fix it.
ctb := context.Background()
ctx, _ := context.WithCancel(ctb)
vmihailenco commented
You can remove ctx, _ := context.WithCancel(ctb)
. All you need to do is pass a non-nil context which is done with ctb := context.Background()
. Nil context.Context
is disallowed in Go.