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 4c4955a commit ee689e7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/cmd/go/internal/load/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@ func MatchPackage(pattern, cwd string) func(*Package) bool {
return false
}

if relToWorkingDir == "." || hasAnyPrefix(relToWorkingDir, ".."+string(filepath.Separator)) {
sep := filepath.Separator
if relToWorkingDir == "." || hasAnyPrefix(relToWorkingDir, ".."+string(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(filepath.Separator))
pathComponents := strings.Split(relToWorkingDir, string(sep))
for _, elem := range pathComponents {
if hasAnyPrefix(elem, ".", "_") || elem == "testdata" {
return false
Expand Down

0 comments on commit ee689e7

Please sign in to comment.