AdamNiederer / cov

An emacs extension for displaying coverage data on your code
GNU General Public License v3.0
78 stars 16 forks source link

Support for Golang's coverage? #58

Open shackra opened 5 months ago

shackra commented 5 months ago

I wish for golang support of the code coverage format, it looks like this:

mode: set
github.com/shackra/keisy-ian/app/bot-trader/app.go:20.89,22.28 2 0
github.com/shackra/keisy-ian/app/bot-trader/app.go:22.28,24.3 1 0
github.com/shackra/keisy-ian/app/bot-trader/app.go:26.2,50.16 4 0
github.com/shackra/keisy-ian/app/bot-trader/app.go:50.16,52.3 1 0
github.com/shackra/keisy-ian/app/bot-trader/app.go:54.2,60.8 2 0
github.com/shackra/keisy-ian/app/bot-trader/app.go:63.49,68.12 4 0
github.com/shackra/keisy-ian/app/bot-trader/app.go:68.12,69.7 1 0
github.com/shackra/keisy-ian/app/bot-trader/app.go:69.7,70.11 1 0
github.com/shackra/keisy-ian/app/bot-trader/app.go:71.22,72.11 1 0
github.com/shackra/keisy-ian/app/bot-trader/app.go:73.22,80.6 1 0
github.com/shackra/keisy-ian/app/bot-trader/app.go:81.15,81.15 0 0
github.com/shackra/keisy-ian/app/bot-trader/app.go:86.2,86.19 1 0
github.com/shackra/keisy-ian/app/bot-trader/configuration_options.go:23.49,24.25 1 0
github.com/shackra/keisy-ian/app/bot-trader/configuration_options.go:24.25,26.3 1 0
github.com/shackra/keisy-ian/app/bot-trader/configuration_options.go:29.50,30.25 1 0
github.com/shackra/keisy-ian/app/bot-trader/configuration_options.go:30.25,32.3 1 0
github.com/shackra/keisy-ian/app/bot-trader/configuration_options.go:35.58,36.25 1 0
github.com/shackra/keisy-ian/app/bot-trader/configuration_options.go:36.25,38.3 1 0
github.com/shackra/keisy-ian/app/bot-trader/configuration_options.go:41.57,42.25 1 0
github.com/shackra/keisy-ian/app/bot-trader/configuration_options.go:42.25,44.3 1 0
github.com/shackra/keisy-ian/app/bot-trader/configuration_options.go:47.53,48.25 1 0
github.com/shackra/keisy-ian/app/bot-trader/configuration_options.go:48.25,50.3 1 0
github.com/shackra/keisy-ian/app/bot-trader/configuration_options.go:53.55,54.25 1 0
github.com/shackra/keisy-ian/app/bot-trader/configuration_options.go:54.25,56.3 1 0
github.com/shackra/keisy-ian/app/bot-trader/configuration_options.go:59.59,60.25 1 0
github.com/shackra/keisy-ian/app/bot-trader/configuration_options.go:60.25,62.3 1 0
github.com/shackra/keisy-ian/app/bot-trader/configuration_options.go:65.64,66.25 1 0
github.com/shackra/keisy-ian/app/bot-trader/configuration_options.go:66.25,68.3 1 0
github.com/shackra/keisy-ian/internal/model/models.go:44.87,55.2 2 0
github.com/shackra/keisy-ian/internal/model/models.go:57.37,59.2 1 0
github.com/shackra/keisy-ian/internal/model/models.go:66.50,73.2 2 1
github.com/shackra/keisy-ian/internal/model/models.go:75.57,82.2 2 1
github.com/shackra/keisy-ian/internal/model/models.go:84.61,91.2 2 1
# ...

With go list -m -json we can guess what part is the name of the module and what's the package:

➜  go list -m -json
{
        "Path": "github.com/shackra/keisy-ian",
        "Main": true,
        "Dir": "/home/jorge/code/crypto/robot-trader/keisy-ian",
        "GoMod": "/home/jorge/code/crypto/robot-trader/keisy-ian/go.mod",
        "GoVersion": "1.21.0"
}

Among many other values.

The format is as follows (taken from a tool that converts this format to lcov):

// Format being parsed is:
//
//  name.go:line.column,line.column numberOfStatements count
//
// e.g.
//
//  github.com/jandelgado/golang-ci-template/main.go:6.14,8.2 1 1