7 ms·
That definitely helps, though you can't use it to introduce new variables with the := syntax: if buf, err := json.Marshal(make(chan int)); err != nil { fmt.P
by xxchan 13y ago
That definitely helps, though you can't use it to introduce new variables with the := syntax:
if buf, err := json.Marshal(make(chan int)); err != nil {
fmt.Println("Ehh..", err)
return
}
In this case, buf will not be available outside of the if statement. Go fmt can already leave your insignificant whitespace as is, I just wish it could also leave the if error != nil statement say in one line instead of formatting it to take three.