deckarep / golang-set

A simple, battle-tested and generic set type for the Go language. Trusted by Docker, 1Password, Ethereum and Hashicorp.
Other
4.15k stars 274 forks source link

how can i free the goroutine #104

Closed letitbezh closed 2 years ago

letitbezh commented 2 years ago

I have use this program in my code,but this cost too many goroutines,how can i solve it image

deckarep commented 2 years ago

Hello,

The set implementation has two APIs for iteration with Iter being one and Each being the other.

The Iter api has a design flaw where you may leak goroutines if you early-return without finishing the consume of it.

The Each does not have this problem. Alternatively you can still use Iter as long as you make sure to iterate completely without stopping early.

letitbezh commented 2 years ago

Thanks for your answer。 i will try to fix my problem

letitbezh commented 2 years ago

Thanks for your answer, i have fixed my problem