I am confused about something with this auto formatting stuff Go forces us to deal with. Here is an example of the way I declare functions with many parameters in other languages:
This allows me to see the function parameters easily without scrolling left and right to read them all. I also make calling the functions the same because I can easily make sure everything matches up. But in Go it appears you are forced to put everything on a single long line with no line breaks.
Not on my system it doesn’t and if it did you should be able to manually do that. However, if you do and you try to compile you get an error about the if statement line not ending with an {
You can see in the playground that it does, it even allows to mix a couple inline and a third in a new line. Just click format in the example: Go Playground - The Go Programming Language
What if are you talking about? There’s neither an if in your example or in lutzhorn’s one. Anyway, ifs must contain the opening bracket in the same line and the same applies to functions/methods. This is not just a style suggestion, it’s enforced by the compiler. The idea behind it is to keep style discussions away from Go code bases as the decision was already made for you, and it helps with tools such as gofmt. I won’t argue in favor or against it, just know that it works this way and at least I got used to it pretty quickly.
I apologize. I meant func not if. However, I just went back and did it again and this time it worked. So I am incorrect and not sure what I did different the other 3 times I tried this.