This repository has been archived by the owner on Apr 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
3 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/AlecAivazis/survey/v2" | ||
) | ||
|
||
// the questions to ask | ||
var simpleQs = []*survey.Question{ | ||
{ | ||
Name: "name", | ||
Prompt: &survey.Input{ | ||
Message: "What is your name?", | ||
}, | ||
Validate: survey.Required, | ||
}, | ||
} | ||
|
||
func main() { | ||
ansmap := make(map[string]interface{}) | ||
|
||
// ask the question | ||
err := survey.Ask(simpleQs, &ansmap, survey.WithShowCursor(true)) | ||
|
||
if err != nil { | ||
fmt.Println(err.Error()) | ||
return | ||
} | ||
// print the answers | ||
fmt.Printf("Your name is %s.\n", ansmap["name"]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters