Skip to content

Commit feeb06c

Browse files
committed
Switching map to a switch
1 parent ec3d848 commit feeb06c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

cli/cmd/release_create.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ Prepared to create release with defaults:
184184
if err != nil {
185185
return err
186186
}
187-
valid := map[string]bool{"y": true, "Y": true}
188-
if !valid[confirmed] {
187+
switch strings.ToLower(confirmed) {
188+
case "n", "N":
189189
return errors.New("configuration declined")
190190
}
191191
fmt.Printf("You can use the --confirm-auto or -y flag in the future to skip this prompt.\n")
@@ -415,12 +415,12 @@ func promptForConfirm() (string, error) {
415415
Templates: templates,
416416
Default: "y",
417417
Validate: func(input string) error {
418-
valid := map[string]bool{"y": true, "Y": true, "n": true, "N": true}
419-
if !valid[input] {
418+
switch strings.ToLower(input) {
419+
case "y", "n":
420+
return nil
421+
default:
420422
return errors.New(`please choose "y" or "n"`)
421423
}
422-
423-
return nil
424424
},
425425
}
426426

0 commit comments

Comments
 (0)