Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

golang 中 遍历一个channel的方法 #11

Open
woshidama323 opened this issue Nov 25, 2021 · 0 comments
Open

golang 中 遍历一个channel的方法 #11

woshidama323 opened this issue Nov 25, 2021 · 0 comments

Comments

@woshidama323
Copy link
Owner

woshidama323 commented Nov 25, 2021

https://go.dev/tour/concurrency/4
要么用 c,ok <- channel 如果 ok =false 说明channel关闭了
或者 for ic := range channel 如果for结束了,说明channel关闭

两个方法都比较安全

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant