Consider the following command:
go tool cover -html=coverage.out
Is there a way to make the resulting HTML dark on light (rather than the default light characters on dark background)?
I did not find anything about this neither in the documentation nor in the help pages referenced therein (go tool cover --help
and go help testflag
)
Not with the built-in tool. There's nothing preventing you from piping the output through some script to change CSS colors, though, or to reference an external CSS file that sets the colors you prefer.
As mentioned by @Flimzy, this is not supported with the built-in tool.
Though, looking at the coverage.html
file output by the cover
tool.
You can do something like this:
go tool cover -o coverage.html -html=coverage.out; sed -i 's/black/whitesmoke/g' coverage.html; sensible-browser coverage.html
which will write the output to coverage.html
using the -o
flag and then use sed
to change occurrences of black to whitesmoke. It will then use your default browser to open the file.
Note #1: Obviously, this will not work once the tool is updated not to output black color background. Though, if this changes, there is probably a lot better support for different color schemes.
Note #2: If you use heat maps -covermode=count
, the light green might look awkward on the smokewhite color. Feel free to try different color accents though.
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