Skip to content

Commit 574a52d

Browse files
committed
add debug printf
1 parent b1d7f32 commit 574a52d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pkg/testcoverage/coverage/module.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package coverage
22

33
import (
44
"bufio"
5+
"fmt"
56
"os"
67
"path/filepath"
78
"strings"
@@ -10,10 +11,16 @@ import (
1011
func findModuleDirective(rootDir string) string {
1112
goModFile := findGoModFile(rootDir)
1213
if goModFile == "" {
14+
fmt.Printf("could not find go.mod file in root dir: %s\n", rootDir)
1315
return ""
1416
}
1517

16-
return readModuleDirective(goModFile)
18+
module := readModuleDirective(goModFile)
19+
if module == "" {
20+
fmt.Println("`module` directive not found")
21+
}
22+
23+
return module
1724
}
1825

1926
func findGoModFile(rootDir string) string {
@@ -45,7 +52,7 @@ func readModuleDirective(filename string) string {
4552

4653
scanner := bufio.NewScanner(file)
4754
for scanner.Scan() {
48-
line := scanner.Text()
55+
line := strings.TrimSpace(scanner.Text())
4956
if strings.HasPrefix(line, "module ") {
5057
return strings.TrimSpace(strings.TrimPrefix(line, "module "))
5158
}

0 commit comments

Comments
 (0)