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

defer close channel golang #2

Open
khanhtc1202 opened this issue Jul 18, 2018 · 0 comments
Open

defer close channel golang #2

khanhtc1202 opened this issue Jul 18, 2018 · 0 comments

Comments

@khanhtc1202
Copy link
Owner

khanhtc1202 commented Jul 18, 2018

close created channels when we're done with them

resultsChan := make(chan results)
errChan := make(chan error)
defer func() {
	close(resultsChan)
	close(errChan)
}()

Note: Channels aren't like files; you don't usually need to close them ( due to this post )

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

No branches or pull requests

1 participant