Skip to content

Commit

Permalink
fixup! cmd/go: fix -coverpkg not ignoring special directories
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewhughes934 committed Mar 24, 2024
1 parent ee689e7 commit 29c8bd9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/cmd/go/internal/load/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ func MatchPackage(pattern, cwd string) func(*Package) bool {
return false
}

sep := filepath.Separator
if relToWorkingDir == "." || hasAnyPrefix(relToWorkingDir, ".."+string(sep)) {
sep := string(filepath.Separator)
if relToWorkingDir == "." || hasAnyPrefix(relToWorkingDir, ".."+sep) {
// Not a special directory so can return immediately
return matchPath(rel)
}

// Otherwise avoid special directories "testdata" or beginning with ".", "_".
pathComponents := strings.Split(relToWorkingDir, string(sep))
pathComponents := strings.Split(relToWorkingDir, sep)
for _, elem := range pathComponents {
if hasAnyPrefix(elem, ".", "_") || elem == "testdata" {
return false
Expand Down

0 comments on commit 29c8bd9

Please sign in to comment.