Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
cmd/gofmt: comments in empty composite literals cannot be indented #22355
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.
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).