Problem with calculating code coverage in Go when some packages are not imported in test files

I am in the process of discovering the Go language. I tried to create a project structure that resembles a Python package:

src:
main.go
services:
pipeline.go
core:
utils.go
test:
pipeline_test.go

However, I am facing a problem trying to calculate code coverage. I ran the command:

go test -coverprofile=coverage.out -covermode=atomic ./tests/...

But this only calculates coverage for imported files, i.e., packages imported in the test files. Packages not imported in tests such as “main” and “core” are not being taken into account. In Python, all files are taken into account. So, my question is whether there is a solution to scan all files even if they are not imported in the test files.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.