I'm not asking for a change here. I already accept that go fmt is the way it is and I'm ok with it. I'm hoping for a reason for
an inconsistency which has already been debated: Un-indented case labels in the switch statement. First, some examples.
Types:
type Something struct {
Field1 int // indented
Field2 int // indented
}
Functions:
func main() {
log.Fatal("GOPHERS!") // indented
}
If:
if something {
log.Fatal("GOPHERS!") // indented
}
Loops:
for {
panic("GOPHERS!") // indented
}
Why aren't the `case` and `default` statements within switch statements similarly indented?
switch blah {
case 1: // not indented!!!
panic(1) // indented
case 2: // not indented!!!
panic(2) // indented
default: // not indented!!!
panic(3) // indented
}
It seems like it should look like this:
switch blah {
case 1: // indented
panic(1) // indented
case 2: // indented
panic(2) // indented
default: // indented
panic(3) // indented
}
The general trend is: indent code within curly braces one level. But this isn't the case with the switch statement. Is there a historical trend for this inconsistency? Or was it a mistake when coding go fmt initially and it just stuck? Or just someone's preference? I can live with any of those answers, just curious. Again, I'm not pushing for a change, just voicing the question that pops into my head every time I write a switch statement in go.
Thanks.