Golang coverprofile output format

Christian Nuss picture Christian Nuss · Jul 14, 2015 · Viewed 12.2k times · Source

I'm trying to make sense of the -coverprofile cover.out option in go test, specifically the format of the file.

Covering server.go for example, yields the output in cover.out:

mode: set
github.com/cnuss/api_server/server.go:47.2,48.16 2 0
github.com/cnuss/api_server/server.go:52.2,53.16 2 0
github.com/cnuss/api_server/server.go:57.2,58.16 2 0
github.com/cnuss/api_server/server.go:62.2,63.16 2 0
github.com/cnuss/api_server/server.go:67.2,68.16 2 0
github.com/cnuss/api_server/server.go:72.2,73.16 2 0
github.com/cnuss/api_server/server.go:77.2,78.16 2 0
  1. What do each of the different columns mean?
  2. Is the format of the output in a "standard" format, e.g. gcov, xunit, etc. and convertable to another format?

Answer

mislav picture mislav · Sep 12, 2016

The fields are:

name.go:line.column,line.column numberOfStatements count

Source