You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, add a non-commented out element like in https://play.golang.org/p/jJE6F2YXDQ, and it will be formatted with the proper indentation. Note that adding an element before the comments also fixes the issue.
Since gofmt seems to not care about the user's choice in this scenario, I would say that comments on their own lines in otherwise empty composite literals should be indented.
Happy to hear counter-arguments or an explanation for the current logic, if it is on purpose. Perhaps there are other fixes too, such as respecting the user's original style (which I think happens in switch cases).
I agree this a bit odd. @mvdan Feel free to give this a shot but I suspect this is going to be rather tricky to get right. Happy to be proven wrong, too.
See https://play.golang.org/p/L5cPyMPVl7. If you press "Format", you'll get:
However, add a non-commented out element like in https://play.golang.org/p/jJE6F2YXDQ, and it will be formatted with the proper indentation. Note that adding an element before the comments also fixes the issue.
Since
gofmt
seems to not care about the user's choice in this scenario, I would say that comments on their own lines in otherwise empty composite literals should be indented.Happy to hear counter-arguments or an explanation for the current logic, if it is on purpose. Perhaps there are other fixes too, such as respecting the user's original style (which I think happens in switch cases).
/cc @griesemer
The text was updated successfully, but these errors were encountered: