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
}
var out []string
for _, i := range choices {
out = append(out, options[i])
out := make([]string, len(choices))
for i, choiceIndex := range choices {
out[i] = options[choiceIndex]
}
return out, nil