From a22690e6d52b2f8dce5e48a4985ff6181999633f Mon Sep 17 00:00:00 2001 From: Tom <73077675+tmzane@users.noreply.github.com> Date: Fri, 26 May 2023 22:03:29 +0300 Subject: [PATCH] fix: invalid map preallocation size (#49) --- utils.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/utils.go b/utils.go index df8f299..73e2131 100644 --- a/utils.go +++ b/utils.go @@ -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. }