-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
cmd/gofmt: inconsistent spacing on slice indices #11497
Comments
It's working as intended. There's a good explanation here.
|
Hmm, I understand that there may be times where one formatting is better than another. But in this case the core piece of the line is exactly the same in both cases. Is there a more specific reasoning that causes this particular difference? |
@tgrosinger You are correct - they should format the same:
The fix is trivial, but in the interest of not introducing lots of changes over huge amounts of code, we haven't pushed it through, and I suggest leaving it as is for now. That said, I've been working on a new version of gofmt (long overdue, hopefully after 1.5 I can concentrate on finishing it) which should solve many of the open gofmt issues. This may be a good time to address this one as well. |
Good to know, thank you. |
gofmt formats this file differently than it used to, and results in what at first seems like an odd inconsistency. Apparently this is by design (see [this][1] and [this][2]), and due to nesting level. [1]: golang/go#11497 [2]: golang/go#12720
What version of Go are you using (go version)?
go version go1.4.2 linux/amd64
What operating system and processor architecture are you using? Ubuntu 14.04
What did you do? Run
gofmt
on below code examplesWhat did you expect to see? Consistent spacing of slice indices
These are two lines within the same function. They vary slightly, but the interesting part is the
[1:len(key-1]
which has inconsistent spacing. Adding spaces to the first one will result in them being removed whengofmt
is run, and removing the spaces from the second will only have them added back.If this is not a bug, please let me know what difference here is causing the spacing to change.
The text was updated successfully, but these errors were encountered: