From 39cdb3232ff030d4b7c509911f0bfba4ace17dbd Mon Sep 17 00:00:00 2001 From: Tom <73077675+tmzane@users.noreply.github.com> Date: Fri, 26 May 2023 01:08:43 +0300 Subject: [PATCH] fix: invalid map preallocation size --- 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. }