-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.
Description
See https://play.golang.org/p/L5cPyMPVl7. If you press "Format", you'll get:
var _ = map[string][]int{
"foo": []string{
1,
2,
},
"bar": []string{
// 3,
// 4,
},
}
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
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.