Skip to content

Commit a22690e

Browse files
authored
fix: invalid map preallocation size (#49)
1 parent 72c164b commit a22690e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

utils.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ func mainModule() (dir string, packages map[string]struct{}, _ error) {
2323
return "", nil, fmt.Errorf("running `go list all`: %w", err)
2424
}
2525

26-
list := strings.TrimSpace(string(out))
27-
packages = make(map[string]struct{}, len(list))
28-
for _, pkg := range strings.Split(list, "\n") {
26+
list := strings.Split(strings.TrimSpace(string(out)), "\n")
27+
packages = make(map[string]struct{}, len(list)*2)
28+
29+
for _, pkg := range list {
2930
packages[pkg] = struct{}{}
3031
packages[pkg+"_test"] = struct{}{} // `*_test` packages belong to the main module, see issue #24.
3132
}

0 commit comments

Comments
 (0)