You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Input:
package main
func main() {
var a, b chan int
go func() { for { a <- <-b } }()
}
Output:
package main
func main() {
var a, b chan int
go func() {
for {
a <- <-b
}
}()
}
The for loop seems to be the trigger to making this go statement multiline. One line
becomes five. It would be nice for concurrent example code like this to have simple,
short one-line closure invocations remain one line.
The text was updated successfully, but these errors were encountered:
Contracted to one line functions/function literals, like `func(x) { return expression }`
are just fine for me. But a loop construct should IMO stand out and deserves those three
lines, even for a one line "body". IOW, I prefer the status quo in this case.
After some experimentation with this proposal (https://golang.org/cl/6846078/)
the Go team decided to leave things as they are: Nobody had convincing arguments in
favor, and there were significant doubts that it would increase readability. By
permitting different styles for 'for' and 'if' statements, code becomes less uniform and
likely less readable.
The text was updated successfully, but these errors were encountered: