Closed lostmaniac closed 3 years ago
To make your example code working, you just need to fix your return values.
package main
import (
"fmt"
"github.com/AlecAivazis/survey/v2"
)
func OptionsSelect(msg string, Opt []string, help string) string {
color := ""
prompt := &survey.Select{
Message: msg,
Options: Opt,
Help: help,
}
aaa := survey.AskOne(prompt, &color)
if aaa != nil {
return aaa.Error()
}
return color
}
func UserInput(msg string) string {
name := ""
prompt := &survey.Input{
Message: msg,
}
bbb := survey.AskOne(prompt, &name)
if bbb != nil {
return bbb.Error()
}
return name
}
func main() {
ddd := UserInput("domefd")
ccc := OptionsSelect("run", []string{"sss", "rrr", "eeee", "qqqq"}, "nnnnn")
fmt.Println(ccc, ddd)
}
thank you very much
I want to use a variable to receive the value set by the user, how should it be received?
thank you very much