VSCode - How to cover all files, not just current package?

As per Code coverage for Go integration tests - The Go Programming Language I am able to generate coverage profile for all packages, however, in VSCode, there is only the option to show coverage for current package. How can I make VSCode show coverage for all packages?

Thanks in advance for your reply.

In VS Code, open a new terminal, under PROBLEMS tab, change the filter setting for Show Active Files Only.

In VSCode, to show code coverage for all packages in a Go project, you need to generate a combined coverage report and then use an extension that supports displaying that coverage.

  1. Generate Combined Coverage Report: Run Go tests with coverage for all packages and generate a combined report:
    go test -coverprofile=coverage.out ./…
  2. Use a Coverage Extension: Install a VSCode extension like “Coverage Gutters” or “Go Test Explorer.” These extensions allow you to load a coverage report and visualize it within VSCode.
  3. Load the Coverage Report:
  • With the extension installed, open the coverage report (coverage.out) in VSCode.
  • Activate the coverage display feature (usually by clicking an icon or running a command from the command palette).
  • The coverage data should now be visible across all packages in your project.

With this setup, you should be able to view coverage across multiple packages in your Go project within VSCode.