It seems gofmt in go1.19 changed its behavior to not allowing indenting based on some heuristics (from go docs: https://tip.golang.org/doc/comment). But this breaks the TODO comment formatting.
This is what I used to have in my code that gofmt accepted.
// TODO: Do some stuff. And this is a long comment so it'll need to
// be wrapped. This is the next line.
Running gofmt gives me this:
// TODO: Do some stuff. And this is a long comment so it'll need to
//
// be wrapped. This is the next line.
I could change it to this but then GoLand doesn't display the TODO properly.
// TODO: Do some stuff. And this is a long comment so it'll need to
// be wrapped. This is the next line.

Any ideas on how to reconcile these problems? I don't understand why the accepted style for TODO has changed.
The custom pattern I used to recognize TODO is
\/(\/|\*)[ ]*\btodo\b(.|\n)*(\*\/|)

Here are steps to set it in Goland
Just put a tab in front of your TODO, like this:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With