Atom编辑器1.15.0版本与Go-Plus插件在函数源代码中有红色背景。

huangapple go评论81阅读模式
英文:

Atom Editor 1.15.0 with Go-Plus has red background in function source code

问题

我已经将Atom更新到最新版本(1.15.0),并更新了所有插件。
我安装了go-plus和go-debug插件。

在Go文件中,我会随机地看到大量方法的红色背景。如果我保存文件,它会在几秒钟内消失。

我以为这是某种警告,但在go-plus中我没有看到任何警告。

有什么想法...红色背景代表什么,如何禁用它?

英文:

I have updated Atom to latest (1.15.0) and updated all plugin.
I have go-plus and go-debug plugins.

I get randomly red background for large number of methods in Go files. If I save file it disappears for few seconds.

Atom编辑器1.15.0版本与Go-Plus插件在函数源代码中有红色背景。

I thought it is some warning but I do not see warning in go-plus.

Any ideas.. What does red bg means and how to disable it?

答案1

得分: 22

如果一个软件包没有测试文件,Atom将对所有源代码行显示默认背景。

如果一个软件包至少有一个测试文件,默认情况下,每次保存时都会运行测试。在运行测试时,行将显示默认背景,当测试完成时,未被测试覆盖的代码行将以红色背景显示。

您可以在设置中更改这些选项:

视图 -> 首选项 -> 软件包 -> go-plus 设置 -> 测试部分
  • 保存时运行测试: 使用此选项可以禁用保存时运行测试。
  • 使用覆盖运行测试: 禁用此选项仍会运行您的测试,但不会以覆盖模式运行它们,因此不会突出显示未经测试的行。
  • 覆盖突出显示模式: 使用此设置可以选择要突出显示的内容,默认情况下,未经测试的代码以红色背景突出显示,您可以选择使用绿色背景突出显示已经测试过的行,或者同时突出显示两者,或者都不突出显示(禁用)。
  • 覆盖显示模式: 这个选项非常方便;默认选项是“突出显示”,它使用不同的背景显示整个行。将其更改为“边栏”,现在只有行号会有不同的背景,而不是代码本身,这样就不会那么令人不安了。

这是在go-plus v5.0中引入的。下面是一个动画GIF,用于突出显示差异:

Atom编辑器1.15.0版本与Go-Plus插件在函数源代码中有红色背景。

英文:

If a package has no test files, Atom will show the default background for all source code lines.

If a package has at least 1 test file, by default tests are run on every save. While the tests are run, the lines are displayed with default background, and when tests complete, code lines that can be tested but were not covered by tests will appear with red background.

You can change this in settings:

View -> Preferences -> Packages -> go-plus settings -> Test section
  • Run Tests On Save: with this you can disable running tests on save
  • Run Tests With Coverage: disabling this will still run your tests, but will not run them with coverage mode, and thus will not highlight untested lines
  • Coverage Highlight Mode: with this setting you can choose what to highlight, by default untested code is highlighted in red background, you can opt to highlight tested lines with green background, or highhlight both, or none of them (disabled)
  • Coverage Display Mode: now this comes handy; default option is highlight, which shows the whole lines using different background. Change it to gutter, and now only the line numbers will have different background, but not the code itself, this is much less disturbing

This was introduced in go-plus v5.0. Here's an animated gif to highlight the differences:

Atom编辑器1.15.0版本与Go-Plus插件在函数源代码中有红色背景。

答案2

得分: 6

红色的代码没有进行测试覆盖。

英文:

The code in red is not covered by tests.

huangapple
  • 本文由 发表于 2017年4月5日 16:31:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/43225916.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定