Skip to content

Commit

Permalink
fix: invalid map preallocation size (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmzane authored May 26, 2023
1 parent 72c164b commit a22690e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ func mainModule() (dir string, packages map[string]struct{}, _ error) {
return "", nil, fmt.Errorf("running `go list all`: %w", err)
}

list := strings.TrimSpace(string(out))
packages = make(map[string]struct{}, len(list))
for _, pkg := range strings.Split(list, "\n") {
list := strings.Split(strings.TrimSpace(string(out)), "\n")
packages = make(map[string]struct{}, len(list)*2)

for _, pkg := range list {
packages[pkg] = struct{}{}
packages[pkg+"_test"] = struct{}{} // `*_test` packages belong to the main module, see issue #24.
}
Expand Down

0 comments on commit a22690e

Please sign in to comment.