Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code organization of if conditions #35925

Closed
RaymondReddington opened this issue Dec 2, 2019 · 1 comment
Closed

code organization of if conditions #35925

RaymondReddington opened this issue Dec 2, 2019 · 1 comment

Comments

@RaymondReddington
Copy link

now if conditions code structure:
if a &
b &
c {
}

i dont think this is clearly if a/b/c is long expression.
how about organize if conditions like this:
if a
& b
& c {
}
i think this will make relations between a,b,c clearly.

@ALTree
Copy link
Member

ALTree commented Dec 2, 2019

Hi,

this is prevented by the automatic semicolon insertion rules. From the spec:

The formal grammar uses semicolons ";" as terminators in a number of productions [...]

When the input is broken into tokens, a semicolon is automatically inserted into the token stream immediately after a line's final token if that token is

  • an identifier

if a would be turned into if a; so it's mandatory that the line ends with the logical operator.

Also the gofmt format has been quite stable since the Go1 release, and at this point it's unlikely to change much.

Closing here.

@ALTree ALTree closed this as completed Dec 2, 2019
@golang golang locked and limited conversation to collaborators Dec 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants