Guiding users with prompts
There are many ways to simply prompt the user, but if you want to create a whole survey that can retrieve information using a variety of different prompts – text input, multi-select, single-select, multi-line text, password, and more – it might be useful to use a preexisting library to handle this for you. Let’s create a generic customer survey using the survey
package.
To show you how to use this package, I’ll create a survey that can prompt the user for different types of input:
- Text input – for example, an email address
- Select – for example, a user’s experience with the CLI
- Multiselect – for example, any issues encountered
- Multiline – for example, open-ended feedback
In the Chapter-10
repository, a survey has been written to handle these four prompts. The questions, stored in the qs
variable, are defined as a slice of *survey.Question
:
questions := []*survey...