confirmDeletion asks the user to type a random string
()
| 64 | |
| 65 | // confirmDeletion asks the user to type a random string |
| 66 | func confirmDeletion() error { |
| 67 | wantChallenge := deletionChallenge() |
| 68 | fmt.Printf("To confirm, please type %q\n", wantChallenge) |
| 69 | |
| 70 | var gotChallenge string |
| 71 | fmt.Scanln(&gotChallenge) |
| 72 | |
| 73 | if gotChallenge != wantChallenge { |
| 74 | return errors.New("confirmation code does not match") |
| 75 | } |
| 76 | |
| 77 | return nil |
| 78 | } |
| 79 | |
| 80 | // deletionChallenge generates a random string |
| 81 | func deletionChallenge() string { |
no test coverage detected