mirror of
https://github.com/tmrts/go-patterns.git
synced 2024-11-22 13:06:09 +03:00
Fix issue of "invalid operation:p"
When ```New``` return a reference, you have to use ```*p``` to access the reference, otherwise it's a pointer.
This commit is contained in:
parent
f978e42036
commit
aac74afa38
@ -29,10 +29,10 @@ Given below is a simple lifecycle example on an object pool.
|
|||||||
p := pool.New(2)
|
p := pool.New(2)
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case obj := <-p:
|
case obj := <-*p:
|
||||||
obj.Do( /*...*/ )
|
obj.Do( /*...*/ )
|
||||||
|
|
||||||
p <- obj
|
*p <- obj
|
||||||
default:
|
default:
|
||||||
// No more objects left — retry later or fail
|
// No more objects left — retry later or fail
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user