{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/11497","labels_url":"https://api.github.com/repos/golang/go/issues/11497/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/11497/comments","events_url":"https://api.github.com/repos/golang/go/issues/11497/events","html_url":"https://github.com/golang/go/issues/11497","id":92429922,"number":11497,"title":"cmd/gofmt: inconsistent spacing on slice indices","user":{"login":"tgrosinger","id":597386,"avatar_url":"https://avatars.githubusercontent.com/u/597386?v=3","gravatar_id":"","url":"https://api.github.com/users/tgrosinger","html_url":"https://github.com/tgrosinger","followers_url":"https://api.github.com/users/tgrosinger/followers","following_url":"https://api.github.com/users/tgrosinger/following{/other_user}","gists_url":"https://api.github.com/users/tgrosinger/gists{/gist_id}","starred_url":"https://api.github.com/users/tgrosinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgrosinger/subscriptions","organizations_url":"https://api.github.com/users/tgrosinger/orgs","repos_url":"https://api.github.com/users/tgrosinger/repos","events_url":"https://api.github.com/users/tgrosinger/events{/privacy}","received_events_url":"https://api.github.com/users/tgrosinger/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-07-01T16:37:38Z","updated_at":"2015-07-02T16:58:02Z","closed_at":null,"body":"**What version of Go are you using (go version)?** `go version go1.4.2 linux/amd64`\r\n**What operating system and processor architecture are you using?** Ubuntu 14.04\r\n**What did you do?** Run `gofmt` on below code examples\r\n**What did you expect to see?** Consistent spacing of slice indices\r\n\r\nThese 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 when `gofmt` is run, and removing the spaces from the second will only have them added back.\r\n\r\nIf this is not a bug, please let me know what difference here is causing the spacing to change.\r\n\r\n```Go\r\nreturn \"?\" + key[1:len(key)-1]\r\n```\r\n\r\n```Go\r\nkey = key[1 : len(key)-1]\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/118092531","html_url":"https://github.com/golang/go/issues/11497#issuecomment-118092531","issue_url":"https://api.github.com/repos/golang/go/issues/11497","id":118092531,"user":{"login":"griesemer","id":8528975,"avatar_url":"https://avatars.githubusercontent.com/u/8528975?v=3","gravatar_id":"","url":"https://api.github.com/users/griesemer","html_url":"https://github.com/griesemer","followers_url":"https://api.github.com/users/griesemer/followers","following_url":"https://api.github.com/users/griesemer/following{/other_user}","gists_url":"https://api.github.com/users/griesemer/gists{/gist_id}","starred_url":"https://api.github.com/users/griesemer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/griesemer/subscriptions","organizations_url":"https://api.github.com/users/griesemer/orgs","repos_url":"https://api.github.com/users/griesemer/repos","events_url":"https://api.github.com/users/griesemer/events{/privacy}","received_events_url":"https://api.github.com/users/griesemer/received_events","type":"User","site_admin":false},"created_at":"2015-07-02T16:58:02Z","updated_at":"2015-07-02T16:58:02Z","body":"@tgrosinger You are correct - they should format the same:\r\n\r\n1) The spacing changes when going from http://play.golang.org/p/ToSuqHfqWu to http://play.golang.org/p/rVyw-A9om1 - the difference is just the added parentheses around the slice expression. However, the slice expression already introduces a form of parentheses (square brackets), so inside there shouldn't be a change.\r\n\r\n2) There are long-standing TODOs for exactly this issue in go/printer:776 (also line 769).\r\n\r\nThe 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.\r\n\r\nThat 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."}}