Goland Formatting Setting for Case Statement
Answered
Hello, when I format my code, the opening brace for the case statement ends up on the next line. Like:
case 25:
{
// do something
}
I want it like:
case 25: {
// do something.
}
I tried the 'Wrapping and Braces' section in the Go Code Style settings. But I dont see enough controls there.
Please sign in to leave a comment.
Hi,
It's default gofmt formatting behavior and there is no way to change it (please see: https://go.dev/play/p/S9zn8tGJ-oR, press Format button and case 1: will be reformatted with braces on newlines).
Also, please see: https://github.com/golang/go/issues/3859
Hy there i can see your post and i must say
Open GoLand Settings:
Navigate to Code Style:
Choose Go Language:
Open the Formatting Options:
Adjust Case Statements Formatting:
Thanks and regards
RyanTemples
Thanks Ryan for the reply. Interestingly, I don't see the 'Code Generation' tab under Go for Code Style. Attached is the screenshot.