[
  {
    "path": ".gitignore",
    "content": "*.json\ncoverage.xml\n\ngocov-xml\n"
  },
  {
    "path": "LICENSE",
    "content": "Copyright (c) 2013 Alexey Palazhchenko\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "Makefile",
    "content": "all: fvb\n\nprepare:\n\tgo get -u github.com/axw/gocov/...\n\tgo get -u github.com/gorilla/mux/...\n\tgocov test -v github.com/gorilla/mux > mux.json\n\nfvb:\n\tgofmt -e -s -w .\n\tgo vet .\n\tgo run ./gocov-xml.go < mux.json > coverage.xml\n\txmllint --valid --noout coverage.xml\n"
  },
  {
    "path": "README.md",
    "content": "# gocov XML\n\nA tool to generate Go coverage in XML report for using with tools/plugins like Jenkins/Cobertura.\n\n> Table of Contents\n\n- [gocov XML](#gocov-xml)\n  - [Installation](#installation)\n  - [Usage](#usage)\n    - [Examples](#examples)\n      - [Generate coverage by passing `gocov` output as input to `gocov-xml`](#generate-coverage-by-passing-gocov-output-as-input-to-gocov-xml)\n      - [Specifying optional source](#specifying-optional-source)\n  - [Authors](#authors)\n\nThis is a simple helper tool for generating XML output in [Cobertura](http://cobertura.sourceforge.net/) format\nfor CIs like [Jenkins](https://wiki.jenkins-ci.org/display/JENKINS/Cobertura+Plugin), [vsts](https://www.visualstudio.com/team-services) and others\nfrom [github.com/axw/gocov](https://github.com/axw/gocov) output.\nThe generated XML output is in the latest [coverage-04.dtd](http://cobertura.sourceforge.net/xml/coverage-04.dtd) schema\n\n## Installation\n\nJust type the following to install the program and its dependencies:\n\nFor Go 1.17 and above:\n\n```bash\ngo install github.com/axw/gocov/gocov@latest\ngo install github.com/AlekSi/gocov-xml@latest\n```\n\nFor previous Go versions:\n\n```bash\ngo get github.com/axw/gocov/...\ngo get github.com/AlekSi/gocov-xml\n```\n\n## Usage\n\n> **NOTE**: `gocov-xml` reads data from the standard input.\n\n```bash\ngocov [-source <absolute path to source>]\n```\n\nWhere,\n\n- **`source`**: Absolute path to source. Defaults to the current working directory.\n\n### Examples\n\n#### Generate coverage by passing `gocov` output as input to `gocov-xml`\n\n```bash\ngocov test github.com/gorilla/mux | gocov-xml > coverage.xml\n```\n\n#### Specifying optional source\n\n```bash\ngocov test github.com/gorilla/mux | gocov-xml -source /abs/path/to/source > coverage.xml\n```\n\n## Authors\n\n- [Alexey Palazhchenko (AlekSi)](https://github.com/AlekSi)\n- [Yukinari Toyota (t-yuki)](https://github.com/t-yuki)\n- [Marin Bek (marinbek)](https://github.com/marinbek)\n- [Alex Castle (acastle)](https://github.com/acastle)\n- [Billy Yao (yaoyaozong)](https://github.com/yaoyaozong)\n- [Abhijith DA (abhijithda)](https://github.com/abhijithda)\n"
  },
  {
    "path": "coverage-04.dtd",
    "content": "<!-- Portions (C) International Organization for Standardization 1986:\n     Permission to copy in any form is granted for use with\n     conforming SGML systems and applications as defined in\n     ISO 8879, provided this notice is included in all copies.\n-->\n\n  <!ELEMENT coverage (sources?,packages)>\n  <!ATTLIST coverage line-rate        CDATA #REQUIRED>\n  <!ATTLIST coverage branch-rate      CDATA #REQUIRED>\n  <!ATTLIST coverage lines-covered    CDATA #REQUIRED>\n  <!ATTLIST coverage lines-valid      CDATA #REQUIRED>\n  <!ATTLIST coverage branches-covered CDATA #REQUIRED>\n  <!ATTLIST coverage branches-valid   CDATA #REQUIRED>\n  <!ATTLIST coverage complexity       CDATA #REQUIRED>\n  <!ATTLIST coverage version          CDATA #REQUIRED>\n  <!ATTLIST coverage timestamp        CDATA #REQUIRED>\n\n  <!ELEMENT sources (source*)>\n\n  <!ELEMENT source (#PCDATA)>\n\n  <!ELEMENT packages (package*)>\n\n  <!ELEMENT package (classes)>\n  <!ATTLIST package name        CDATA #REQUIRED>\n  <!ATTLIST package line-rate   CDATA #REQUIRED>\n  <!ATTLIST package branch-rate CDATA #REQUIRED>\n  <!ATTLIST package complexity  CDATA #REQUIRED>\n\n  <!ELEMENT classes (class*)>\n\n  <!ELEMENT class (methods,lines)>\n  <!ATTLIST class name        CDATA #REQUIRED>\n  <!ATTLIST class filename    CDATA #REQUIRED>\n  <!ATTLIST class line-rate   CDATA #REQUIRED>\n  <!ATTLIST class branch-rate CDATA #REQUIRED>\n  <!ATTLIST class complexity  CDATA #REQUIRED>\n\n  <!ELEMENT methods (method*)>\n\n  <!ELEMENT method (lines)>\n  <!ATTLIST method name        CDATA #REQUIRED>\n  <!ATTLIST method signature   CDATA #REQUIRED>\n  <!ATTLIST method line-rate   CDATA #REQUIRED>\n  <!ATTLIST method branch-rate CDATA #REQUIRED>\n  <!ATTLIST method complexity  CDATA #REQUIRED>\n\n  <!ELEMENT lines (line*)>\n\n  <!ELEMENT line (conditions*)>\n  <!ATTLIST line number CDATA #REQUIRED>\n  <!ATTLIST line hits   CDATA #REQUIRED>\n  <!ATTLIST line branch CDATA \"false\">\n  <!ATTLIST line condition-coverage CDATA \"100%\">\n\n  <!ELEMENT conditions (condition*)>\n\n  <!ELEMENT condition EMPTY>\n  <!ATTLIST condition number CDATA #REQUIRED>\n  <!ATTLIST condition type CDATA #REQUIRED>\n  <!ATTLIST condition coverage CDATA #REQUIRED>\n"
  },
  {
    "path": "coverage-with-data.xml",
    "content": "<?xml version=\"1.0\"?>\n<!--DOCTYPE coverage SYSTEM \"http://cobertura.sourceforge.net/xml/coverage-03.dtd\"-->\n\n<coverage line-rate=\"0.9\" branch-rate=\"0.75\" version=\"1.9\" timestamp=\"1187350905008\">\n\t<sources>\n\t\t<source>C:/local/mvn-coverage-example/src/main/java</source>\n\t\t<source>--source</source>\n\t</sources>\n\t<packages>\n\t\t<package name=\"\" line-rate=\"1.0\" branch-rate=\"1.0\" complexity=\"1.0\">\n\t\t\t<classes>\n\t\t\t\t<class name=\"Main\" filename=\"Main.java\" line-rate=\"1.0\" branch-rate=\"1.0\" complexity=\"1.0\">\n\t\t\t\t\t<methods>\n\t\t\t\t\t\t<method name=\"&lt;init&gt;\" signature=\"()V\" line-rate=\"1.0\" branch-rate=\"1.0\">\n\t\t\t\t\t\t\t<lines>\n\t\t\t\t\t\t\t\t<line number=\"10\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t\t</lines>\n\t\t\t\t\t\t</method>\n\t\t\t\t\t\t<method name=\"doSearch\" signature=\"()V\" line-rate=\"1.0\" branch-rate=\"1.0\">\n\t\t\t\t\t\t\t<lines>\n\t\t\t\t\t\t\t\t<line number=\"23\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t\t\t<line number=\"25\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t\t\t<line number=\"26\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t\t\t<line number=\"28\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t\t\t<line number=\"29\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t\t\t<line number=\"30\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t\t</lines>\n\t\t\t\t\t\t</method>\n\t\t\t\t\t\t<method name=\"main\" signature=\"([Ljava/lang/String;)V\" line-rate=\"1.0\" branch-rate=\"1.0\">\n\t\t\t\t\t\t\t<lines>\n\t\t\t\t\t\t\t\t<line number=\"16\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t\t\t<line number=\"17\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t\t\t<line number=\"18\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t\t\t<line number=\"19\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t\t</lines>\n\t\t\t\t\t\t</method>\n\t\t\t\t\t</methods>\n\t\t\t\t\t<lines>\n\t\t\t\t\t\t<line number=\"10\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t<line number=\"16\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t<line number=\"17\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t<line number=\"18\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t<line number=\"19\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t<line number=\"23\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t<line number=\"25\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t<line number=\"26\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t<line number=\"28\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t<line number=\"29\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t<line number=\"30\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t</lines>\n\t\t\t\t</class>\n\t\t\t</classes>\n\t\t</package>\n\t\t<package name=\"search\" line-rate=\"0.8421052631578947\" branch-rate=\"0.75\" complexity=\"3.25\">\n\t\t\t<classes>\n\t\t\t\t<class name=\"search.BinarySearch\" filename=\"search/BinarySearch.java\" line-rate=\"0.9166666666666666\" branch-rate=\"0.8333333333333334\" complexity=\"3.0\">\n\t\t\t\t\t<methods>\n\t\t\t\t\t\t<method name=\"&lt;init&gt;\" signature=\"()V\" line-rate=\"1.0\" branch-rate=\"1.0\">\n\t\t\t\t\t\t\t<lines>\n\t\t\t\t\t\t\t\t<line number=\"12\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t\t</lines>\n\t\t\t\t\t\t</method>\n\t\t\t\t\t\t<method name=\"find\" signature=\"([II)I\" line-rate=\"0.9090909090909091\" branch-rate=\"0.8333333333333334\">\n\t\t\t\t\t\t\t<lines>\n\t\t\t\t\t\t\t\t<line number=\"16\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t\t\t<line number=\"18\" hits=\"12\" branch=\"true\" condition-coverage=\"100% (2/2)\">\n\t\t\t\t\t\t\t\t\t<conditions>\n\t\t\t\t\t\t\t\t\t\t<condition number=\"0\" type=\"jump\" coverage=\"100%\"/>\n\t\t\t\t\t\t\t\t\t</conditions>\n\t\t\t\t\t\t\t\t</line>\n\t\t\t\t\t\t\t\t<line number=\"20\" hits=\"9\" branch=\"false\"/>\n\t\t\t\t\t\t\t\t<line number=\"21\" hits=\"9\" branch=\"false\"/>\n\t\t\t\t\t\t\t\t<line number=\"23\" hits=\"9\" branch=\"true\" condition-coverage=\"50% (1/2)\">\n\t\t\t\t\t\t\t\t\t<conditions>\n\t\t\t\t\t\t\t\t\t\t<condition number=\"0\" type=\"jump\" coverage=\"50%\"/>\n\t\t\t\t\t\t\t\t\t</conditions>\n\t\t\t\t\t\t\t\t</line>\n\t\t\t\t\t\t\t\t<line number=\"24\" hits=\"0\" branch=\"false\"/>\n\t\t\t\t\t\t\t\t<line number=\"25\" hits=\"9\" branch=\"true\" condition-coverage=\"100% (2/2)\">\n\t\t\t\t\t\t\t\t\t<conditions>\n\t\t\t\t\t\t\t\t\t\t<condition number=\"0\" type=\"jump\" coverage=\"100%\"/>\n\t\t\t\t\t\t\t\t\t</conditions>\n\t\t\t\t\t\t\t\t</line>\n\t\t\t\t\t\t\t\t<line number=\"26\" hits=\"6\" branch=\"false\"/>\n\t\t\t\t\t\t\t\t<line number=\"28\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t\t\t<line number=\"29\" hits=\"9\" branch=\"false\"/>\n\t\t\t\t\t\t\t\t<line number=\"31\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t\t</lines>\n\t\t\t\t\t\t</method>\n\t\t\t\t\t</methods>\n\t\t\t\t\t<lines>\n\t\t\t\t\t\t<line number=\"12\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t<line number=\"16\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t<line number=\"18\" hits=\"12\" branch=\"true\" condition-coverage=\"100% (2/2)\">\n\t\t\t\t\t\t\t<conditions>\n\t\t\t\t\t\t\t\t<condition number=\"0\" type=\"jump\" coverage=\"100%\"/>\n\t\t\t\t\t\t\t</conditions>\n\t\t\t\t\t\t</line>\n\t\t\t\t\t\t<line number=\"20\" hits=\"9\" branch=\"false\"/>\n\t\t\t\t\t\t<line number=\"21\" hits=\"9\" branch=\"false\"/>\n\t\t\t\t\t\t<line number=\"23\" hits=\"9\" branch=\"true\" condition-coverage=\"50% (1/2)\">\n\t\t\t\t\t\t\t<conditions>\n\t\t\t\t\t\t\t\t<condition number=\"0\" type=\"jump\" coverage=\"50%\"/>\n\t\t\t\t\t\t\t</conditions>\n\t\t\t\t\t\t</line>\n\t\t\t\t\t\t<line number=\"24\" hits=\"0\" branch=\"false\"/>\n\t\t\t\t\t\t<line number=\"25\" hits=\"9\" branch=\"true\" condition-coverage=\"100% (2/2)\">\n\t\t\t\t\t\t\t<conditions>\n\t\t\t\t\t\t\t\t<condition number=\"0\" type=\"jump\" coverage=\"100%\"/>\n\t\t\t\t\t\t\t</conditions>\n\t\t\t\t\t\t</line>\n\t\t\t\t\t\t<line number=\"26\" hits=\"6\" branch=\"false\"/>\n\t\t\t\t\t\t<line number=\"28\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t<line number=\"29\" hits=\"9\" branch=\"false\"/>\n\t\t\t\t\t\t<line number=\"31\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t</lines>\n\t\t\t\t</class>\n\t\t\t\t<class name=\"search.ISortedArraySearch\" filename=\"search/ISortedArraySearch.java\" line-rate=\"1.0\" branch-rate=\"1.0\" complexity=\"1.0\">\n\t\t\t\t\t<methods>\n\t\t\t\t\t</methods>\n\t\t\t\t\t<lines>\n\t\t\t\t\t</lines>\n\t\t\t\t</class>\n\t\t\t\t<class name=\"search.LinearSearch\" filename=\"search/LinearSearch.java\" line-rate=\"0.7142857142857143\" branch-rate=\"0.6666666666666666\" complexity=\"6.0\">\n\t\t\t\t\t<methods>\n\t\t\t\t\t\t<method name=\"&lt;init&gt;\" signature=\"()V\" line-rate=\"1.0\" branch-rate=\"1.0\">\n\t\t\t\t\t\t\t<lines>\n\t\t\t\t\t\t\t\t<line number=\"9\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t\t</lines>\n\t\t\t\t\t\t</method>\n\t\t\t\t\t\t<method name=\"find\" signature=\"([II)I\" line-rate=\"0.6666666666666666\" branch-rate=\"0.6666666666666666\">\n\t\t\t\t\t\t\t<lines>\n\t\t\t\t\t\t\t\t<line number=\"13\" hits=\"9\" branch=\"true\" condition-coverage=\"50% (1/2)\">\n\t\t\t\t\t\t\t\t\t<conditions>\n\t\t\t\t\t\t\t\t\t\t<condition number=\"0\" type=\"jump\" coverage=\"50%\"/>\n\t\t\t\t\t\t\t\t\t</conditions>\n\t\t\t\t\t\t\t\t</line>\n\t\t\t\t\t\t\t\t<line number=\"15\" hits=\"9\" branch=\"true\" condition-coverage=\"100% (2/2)\">\n\t\t\t\t\t\t\t\t\t<conditions>\n\t\t\t\t\t\t\t\t\t\t<condition number=\"0\" type=\"jump\" coverage=\"100%\"/>\n\t\t\t\t\t\t\t\t\t</conditions>\n\t\t\t\t\t\t\t\t</line>\n\t\t\t\t\t\t\t\t<line number=\"16\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t\t\t<line number=\"17\" hits=\"6\" branch=\"true\" condition-coverage=\"50% (1/2)\">\n\t\t\t\t\t\t\t\t\t<conditions>\n\t\t\t\t\t\t\t\t\t\t<condition number=\"0\" type=\"jump\" coverage=\"50%\"/>\n\t\t\t\t\t\t\t\t\t</conditions>\n\t\t\t\t\t\t\t\t</line>\n\t\t\t\t\t\t\t\t<line number=\"19\" hits=\"0\" branch=\"false\"/>\n\t\t\t\t\t\t\t\t<line number=\"24\" hits=\"0\" branch=\"false\"/>\n\t\t\t\t\t\t\t</lines>\n\t\t\t\t\t\t</method>\n\t\t\t\t\t</methods>\n\t\t\t\t\t<lines>\n\t\t\t\t\t\t<line number=\"9\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t<line number=\"13\" hits=\"9\" branch=\"true\" condition-coverage=\"50% (1/2)\">\n\t\t\t\t\t\t\t<conditions>\n\t\t\t\t\t\t\t\t<condition number=\"0\" type=\"jump\" coverage=\"50%\"/>\n\t\t\t\t\t\t\t</conditions>\n\t\t\t\t\t\t</line>\n\t\t\t\t\t\t<line number=\"15\" hits=\"9\" branch=\"true\" condition-coverage=\"100% (2/2)\">\n\t\t\t\t\t\t\t<conditions>\n\t\t\t\t\t\t\t\t<condition number=\"0\" type=\"jump\" coverage=\"100%\"/>\n\t\t\t\t\t\t\t</conditions>\n\t\t\t\t\t\t</line>\n\t\t\t\t\t\t<line number=\"16\" hits=\"3\" branch=\"false\"/>\n\t\t\t\t\t\t<line number=\"17\" hits=\"6\" branch=\"true\" condition-coverage=\"50% (1/2)\">\n\t\t\t\t\t\t\t<conditions>\n\t\t\t\t\t\t\t\t<condition number=\"0\" type=\"jump\" coverage=\"50%\"/>\n\t\t\t\t\t\t\t</conditions>\n\t\t\t\t\t\t</line>\n\t\t\t\t\t\t<line number=\"19\" hits=\"0\" branch=\"false\"/>\n\t\t\t\t\t\t<line number=\"24\" hits=\"0\" branch=\"false\"/>\n\t\t\t\t\t</lines>\n\t\t\t\t</class>\n\t\t\t</classes>\n\t\t</package>\n\t</packages>\n</coverage>\n"
  },
  {
    "path": "go.mod",
    "content": "module github.com/AlekSi/gocov-xml\n\ngo 1.13\n\nrequire github.com/axw/gocov v1.1.0\n"
  },
  {
    "path": "go.sum",
    "content": "github.com/axw/gocov v1.1.0 h1:y5U1krExoJDlb/kNtzxyZQmNRprFOFCutWbNjcQvmVM=\ngithub.com/axw/gocov v1.1.0/go.mod h1:H9G4tivgdN3pYSSVrTFBr6kGDCmAkgbJhtxFzAvgcdw=\ngithub.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=\ngithub.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=\ngithub.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=\ngithub.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=\ngolang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=\ngolang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=\ngolang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=\ngolang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=\ngolang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=\ngolang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=\ngopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=\ngopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=\n"
  },
  {
    "path": "gocov-xml.go",
    "content": "package main\n\nimport (\n\t\"encoding/json\"\n\t\"encoding/xml\"\n\t\"flag\"\n\t\"fmt\"\n\t\"go/token\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"sort\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/axw/gocov\"\n)\n\n// Coverage information\ntype Coverage struct {\n\tXMLName         xml.Name  `xml:\"coverage\"`\n\tLineRate        float32   `xml:\"line-rate,attr\"`\n\tBranchRate      float32   `xml:\"branch-rate,attr\"`\n\tLinesCovered    float32   `xml:\"lines-covered,attr\"`\n\tLinesValid      int64     `xml:\"lines-valid,attr\"`\n\tBranchesCovered int64     `xml:\"branches-covered,attr\"`\n\tBranchesValid   int64     `xml:\"branches-valid,attr\"`\n\tComplexity      float32   `xml:\"complexity,attr\"`\n\tVersion         string    `xml:\"version,attr\"`\n\tTimestamp       int64     `xml:\"timestamp,attr\"`\n\tPackages        []Package `xml:\"packages>package\"`\n\tSources         []string  `xml:\"sources>source\"`\n}\n\n// Package information\ntype Package struct {\n\tName       string  `xml:\"name,attr\"`\n\tLineRate   float32 `xml:\"line-rate,attr\"`\n\tBranchRate float32 `xml:\"branch-rate,attr\"`\n\tComplexity float32 `xml:\"complexity,attr\"`\n\tClasses    []Class `xml:\"classes>class\"`\n\tLineCount  int64   `xml:\"line-count,attr\"`\n\tLineHits   int64   `xml:\"line-hits,attr\"`\n}\n\n// Class information\ntype Class struct {\n\tName       string   `xml:\"name,attr\"`\n\tFilename   string   `xml:\"filename,attr\"`\n\tLineRate   float32  `xml:\"line-rate,attr\"`\n\tBranchRate float32  `xml:\"branch-rate,attr\"`\n\tComplexity float32  `xml:\"complexity,attr\"`\n\tMethods    []Method `xml:\"methods>method\"`\n\tLines      []Line   `xml:\"lines>line\"`\n\tLineCount  int64    `xml:\"line-count,attr\"`\n\tLineHits   int64    `xml:\"line-hits,attr\"`\n}\n\n// Method information\ntype Method struct {\n\tName       string  `xml:\"name,attr\"`\n\tSignature  string  `xml:\"signature,attr\"`\n\tLineRate   float32 `xml:\"line-rate,attr\"`\n\tBranchRate float32 `xml:\"branch-rate,attr\"`\n\tComplexity float32 `xml:\"complexity,attr\"`\n\tLines      []Line  `xml:\"lines>line\"`\n\tLineCount  int64   `xml:\"line-count,attr\"`\n\tLineHits   int64   `xml:\"line-hits,attr\"`\n}\n\n// Line information\ntype Line struct {\n\tNumber int   `xml:\"number,attr\"`\n\tHits   int64 `xml:\"hits,attr\"`\n}\n\nfunc main() {\n\tsourcePathPtr := flag.String(\n\t\t\"source\",\n\t\t\"\",\n\t\t\"Absolute path to source. Defaults to current working directory.\",\n\t)\n\n\tflag.Parse()\n\n\t// Parse the commandline arguments.\n\tvar sourcePath string\n\tvar err error\n\tif *sourcePathPtr != \"\" {\n\t\tsourcePath = *sourcePathPtr\n\t\tif !filepath.IsAbs(sourcePath) {\n\t\t\tpanic(fmt.Sprintf(\"Source path is a relative path: %s\", sourcePath))\n\t\t}\n\t} else {\n\t\tsourcePath, err = os.Getwd()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\n\tsources := make([]string, 1)\n\tsources[0] = sourcePath\n\tvar r struct{ Packages []gocov.Package }\n\tvar totalLines, totalHits int64\n\terr = json.NewDecoder(os.Stdin).Decode(&r)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfset := token.NewFileSet()\n\ttokenFiles := make(map[string]*token.File)\n\n\t// convert packages\n\tpackages := make([]Package, len(r.Packages))\n\tfor i, gPackage := range r.Packages {\n\t\t// group functions by filename and \"class\" (type)\n\t\tfiles := make(map[string]map[string]*Class)\n\t\tfor _, gFunction := range gPackage.Functions {\n\t\t\t// get the releative path by base path.\n\t\t\tfpath, err := filepath.Rel(sourcePath, gFunction.File)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t\tclasses := files[fpath]\n\t\t\tif classes == nil {\n\t\t\t\t// group functions by \"class\" (type) in a File\n\t\t\t\tclasses = make(map[string]*Class)\n\t\t\t\tfiles[fpath] = classes\n\t\t\t}\n\n\t\t\ts := strings.Split(\"-.\"+gFunction.Name, \".\") // className is \"-\" for package-level functions\n\t\t\tclassName, methodName := s[len(s)-2], s[len(s)-1]\n\t\t\tclass := classes[className]\n\t\t\tif class == nil {\n\t\t\t\tclass = &Class{Name: className, Filename: fpath, Methods: []Method{}, Lines: []Line{}}\n\t\t\t\tclasses[className] = class\n\t\t\t}\n\n\t\t\t// from github.com/axw/gocov /gocov/annotate.go#printFunctionSource\n\t\t\t// Load the file for line information. Probably overkill, maybe\n\t\t\t// just compute the lines from offsets in here.\n\t\t\tsetContent := false\n\t\t\ttokenFile := tokenFiles[gFunction.File]\n\t\t\tif tokenFile == nil {\n\t\t\t\tinfo, err := os.Stat(gFunction.File)\n\t\t\t\tif err != nil {\n\t\t\t\t\tpanic(err)\n\t\t\t\t}\n\t\t\t\ttokenFile = fset.AddFile(gFunction.File, fset.Base(), int(info.Size()))\n\t\t\t\tsetContent = true\n\t\t\t}\n\n\t\t\ttokenData, err := ioutil.ReadFile(gFunction.File)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t\tif setContent {\n\t\t\t\t// This processes the content and records line number info.\n\t\t\t\ttokenFile.SetLinesForContent(tokenData)\n\t\t\t}\n\n\t\t\t// convert statements to lines\n\t\t\tlines := make([]Line, len(gFunction.Statements))\n\t\t\tvar funcHits int\n\t\t\tfor i, s := range gFunction.Statements {\n\t\t\t\tlineno := tokenFile.Line(tokenFile.Pos(s.Start))\n\t\t\t\tline := Line{Number: lineno, Hits: s.Reached}\n\t\t\t\tif int(s.Reached) > 0 {\n\t\t\t\t\tfuncHits++\n\t\t\t\t}\n\t\t\t\tlines[i] = line\n\t\t\t\tclass.Lines = append(class.Lines, line)\n\t\t\t}\n\t\t\tlineRate := float32(funcHits) / float32(len(gFunction.Statements))\n\n\t\t\tclass.Methods = append(class.Methods, Method{Name: methodName, Lines: lines, LineRate: lineRate})\n\t\t\tclass.LineCount += int64(len(gFunction.Statements))\n\t\t\tclass.LineHits += int64(funcHits)\n\t\t}\n\n\t\t// fill package with \"classes\"\n\t\tp := Package{Name: gPackage.Name, Classes: []Class{}}\n\t\tfor _, classes := range files {\n\t\t\tfor _, class := range classes {\n\t\t\t\tp.LineCount += class.LineCount\n\t\t\t\tp.LineHits += class.LineHits\n\t\t\t\tclass.LineRate = float32(class.LineHits) / float32(class.LineCount)\n\t\t\t\tp.Classes = append(p.Classes, *class)\n\t\t\t\tsort.Slice(class.Methods, func(i, j int) bool {\n\t\t\t\t\treturn class.Methods[i].Name < class.Methods[j].Name\n\t\t\t\t})\n\t\t\t\tsort.Slice(class.Lines, func(i, j int) bool {\n\t\t\t\t\treturn class.Lines[i].Number < class.Lines[j].Number\n\t\t\t\t})\n\t\t\t}\n\t\t\tp.LineRate = float32(p.LineHits) / float32(p.LineCount)\n\t\t}\n\t\tsort.Slice(p.Classes, func(i, j int) bool {\n\t\t\tif p.Classes[i].Filename != p.Classes[j].Filename {\n\t\t\t\treturn p.Classes[i].Filename < p.Classes[j].Filename\n\t\t\t}\n\t\t\treturn p.Classes[i].Name < p.Classes[j].Name\n\t\t})\n\t\tpackages[i] = p\n\t\ttotalLines += p.LineCount\n\t\ttotalHits += p.LineHits\n\t}\n\n\tcoverage := Coverage{Sources: sources, Packages: packages, Timestamp: time.Now().UnixNano() / int64(time.Millisecond), LinesCovered: float32(totalHits), LinesValid: int64(totalLines), LineRate: float32(totalHits) / float32(totalLines)}\n\n\tfmt.Printf(xml.Header)\n\tfmt.Printf(\"<!DOCTYPE coverage SYSTEM \\\"http://cobertura.sourceforge.net/xml/coverage-04.dtd\\\">\\n\")\n\n\tencoder := xml.NewEncoder(os.Stdout)\n\tencoder.Indent(\"\", \"\\t\")\n\terr = encoder.Encode(coverage)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println()\n}\n"
  }
]