This file does not refer to con.go, and the ranges are wrong (or, at best, imprecise) for that file, and completely wrong for main.go.
A minimal improvement would be for the coverage tool to change user's //line directives to bare // comments, so that the coverage data corresponds to the file presented to the tool. [Getting results that point to files mentioned in //line directives would require changing the format of the tables in the generated code, at least. Even then the results might be peculiar, for instance if the generated file were run through go fmt.]
The text was updated successfully, but these errors were encountered:
In order to be recognized as a line directive, the comment must start with //line or /*line followed by a space, and must contain at least one colon. The //line form must start at the beginning of a line. A line directive specifies the source position for the character immediately following the comment as having come from the specified file, line and column: For a //line comment, this is the first character of the next line, and for a /*line comment this is the character position immediately following the closing */.
The //line format wouldn't be too hard to replace because it has to be at the start of the line, but /*line ...*/ is more complicated because it can be anywhere on a line. However unlikely, it could be inside a string, so it is not just a simple replace... replacing it if it is inside a string, would change the program behavior.
I suppose one approach would be to just fix it for //line type directives (by replacing those lines with //) and leave /*line ...*/ as-is, and it would be a known limitation of cover.