Allocate memory for output slice in pkgPrompt() using make()

This commit is contained in:
Elara 2022-09-26 19:11:30 -07:00
parent 095630ab91
commit f00fc25734
1 changed files with 3 additions and 3 deletions

View File

@ -160,9 +160,9 @@ func pkgPrompt(options []string) ([]string, error) {
return nil, err return nil, err
} }
var out []string out := make([]string, len(choices))
for _, i := range choices { for i, choiceIndex := range choices {
out = append(out, options[i]) out[i] = options[choiceIndex]
} }
return out, nil return out, nil