INNER CODE UNIT · Go

main

manifoldco/promptui · _examples/prompt/main.go:11

func main() {
	validate := func(input string) error {
		_, err := strconv.ParseFloat(input, 64)
		if err != nil {
			return errors.New("Invalid number")
		}
		return nil
	}

	prompt := promptui.Prompt{
		Label:    "Number",
		Validate: validate,
	}

	result, err := prompt.Run()

	if err != nil {
		fmt.Printf("Prompt failed %v\n", err)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…