# README
Survey
A library for building interactive prompts. Heavily inspired by the great inquirer.js.
package main
import (
"fmt"
"gopkg.in/alecaivazis/survey.v0"
)
// the questions to ask
var qs = []*survey.Question{
{
Name: "name",
Prompt: &survey.Input{"What is your name?", ""},
Validate: survey.Required,
},
{
Name: "color",
Prompt: &survey.Choice{
Message: "Choose a color:",
Choices: []string{"red", "blue", "green"},
Default: "red",
},
},
}
func main() {
answers, err := survey.Ask(qs)
if err != nil {
fmt.Println("\n", err.Error())
return
}
fmt.Printf("%s chose %s.", answers["name"], answers["color"])
}
# Functions
Ask performs the prompt loop.
AskOne asks a single question without performing validation on the answer.
AskOneValidate asks a single question and validates the answer with v.
ComposeValidators is a variadic function used to create one validator from many.
MaxLength requires that the string is no longer than the specified value.
MinLength requires that the string is longer or equal in length to the specified value.
Required does not allow an empty value.
No description provided by the author
# Constants
the template used to show the list of Selects.
No description provided by the author
# Variables
Templates with Color formatting.
No description provided by the author
No description provided by the author
Templates with Color formatting.
No description provided by the author
No description provided by the author
Templates with Color formatting.
No description provided by the author
# Structs
Choice is a prompt that presents a list of various options to the user for them to select using the arrow keys and enter.
Confirm is a regular text input that accept yes/no answers.
data available to the templates when processing.
Input is a regular text input that prints each character the user types on the screen and accepts the input with the enter key.
data available to the templates when processing.
MultiChoice is a prompt that presents a list of various options to the user for them to select using the arrow keys and enter.
data available to the templates when processing.
Password is like a normal Input but the text shows up as *'s and there is no default.
Question is the core data structure for a survey questionnaire.
the data available to the templates when processing.
# Interfaces
Prompt is the primary interface for the objects that can take user input and return a string value.
# Type aliases
Validator is a function passed to a Question in order to redefine.