-
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: extra indentations when adding comments #32480
Comments
Yes, adding a line comment after breaking the first line adds an extra tab. But I am curious whether you discovered this in some real-world situation or in a different case ? Note that For reference, this happens with 1.12.4 and also tip at |
Yes, this example just have dummy methods for simplicity. But in my real-world example, I have longer names for these methods that get parameters, and adding line breaks make the code more clear to me.
I'm not sure what are you referring a weird code. The comments or the line breaks? My current "hack" to solve this is to change the code block below: func main() {
result, err := client.Search(). // create a search client.
Index("twitter"). // search in index "twitter"
Query(elastic.NewMatchAllQuery()). // return all results, but ...
SearchType("count"). // ... do not return hits, just the count
Aggregation("timeline", timeline). // add our aggregation to the query
Pretty(true). // pretty print request and response JSON
Do(context.Background()) // execute
} To this (adding line break between func main() {
result, err := client.
Search(). // create a search client.
Index("twitter"). // search in index "twitter"
Query(elastic.NewMatchAllQuery()). // return all results, but ...
SearchType("count"). // ... do not return hits, just the count
Aggregation("timeline", timeline). // add our aggregation to the query
Pretty(true). // pretty print request and response JSON
Do(context.Background()) // execute
} I would be happy to fix/change this, but let's wait for @griesemer input before. |
Indeed, ES API is written this way. I was referring to the line breaks. |
Looks like something we should try to fix. |
@griesemer, would you mind if I take it? |
@a8m You're welcome to give it a shot. But to be fair, I should let you know that I won't have time to help with this or answer detailed questions through the end of July at least. Also any review will have to wait at least that long. |
I encounter an issue with
gofmt
, where adding a comment to the first line causes extra indentation to the rest of the lines.For example, giving this block of code:
Adding a comment (
//
) afterBar()
adds extra indentations to the lines below:Playground
Same for this case:
Playground
Maybe I miss something, but I expect the formatting to be as follow:
The text was updated successfully, but these errors were encountered: