英文:
Why does gofmt remove indented TODO formatting?
问题
在go1.19中,似乎gofmt改变了其行为,不再允许根据一些启发式规则进行缩进(来自go文档:https://tip.golang.org/doc/comment)。但这破坏了TODO注释的格式。
这是我以前在我的代码中使用的,gofmt接受了。
// TODO: Do some stuff. And this is a long comment so it'll need to
// be wrapped. This is the next line.
运行gofmt给我这个结果:
// TODO: Do some stuff. And this is a long comment so it'll need to
//
// be wrapped. This is the next line.
我可以将其更改为以下内容,但是GoLand无法正确显示TODO。
// TODO: Do some stuff. And this is a long comment so it'll need to
// be wrapped. This is the next line.
对于如何解决这些问题有什么想法吗?我不明白为什么TODO的接受样式已经改变。
英文:
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.
答案1
得分: 1
答案2
得分: 0
我使用的自定义模式来识别TODO
是:
\/(\/|\*)[ ]*\btodo\b(.|\n)*(\*\/|)
以下是在Goland中设置它的步骤:
- 在设置/首选项对话框中,选择编辑器| TODO。
- 使用正则表达式来指定自定义模式。
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论