-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
Fix test TestServer #27
Conversation
* typo in comments * loop variable captured in function literal See https://golang.org/doc/faq#closures_and_goroutines
See this example: playground In a nutshell, if you capture a loop variable in an inner goroutine, you can't predict what value it will have on actual execution. Most of the time you'll only get a few samples repeated many times. |
Yeah, but you do not fix the issue by removing the code, you should pass name to the goroutine to fix it properly, the same way as done by id. |
I'm sorry I don't understand. |
I'm probably missing coffee, I thought you removed the code, but you added. Now things do make sense. Yet, if you pass the variable to the goroutine, it looks cleaner than redefining it. Perhaps you can change it. |
I'm not looking for easier, I'm looking for a cleaner solution. What someone would put an eye on and get right at it, redefining it is something very Go specific, that from Python, Java or other language perspective makes zero sense. |
Do as you wish, it's your project. |
id is already a parameter, leaving name outside is not concise. Two ways of doing the same thing in the same scope. |
See https://golang.org/doc/faq#closures_and_goroutines