【发布时间】:2022-10-08 14:49:14
【问题描述】:
似乎 go1.19 中的 gofmt 将其行为更改为不允许基于一些启发式的缩进(来自 go docs: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 的公认风格发生了变化。
【问题讨论】:
-
从您提供的链接中,“在这两个中,最后一行都是缩进的,使其成为一个代码块。解决方法是取消缩进这些行。”似乎 Go 认为它不应该缩进。也许 GoLand 需要改变?