duansaoguan7955
2018-10-24 22:53
浏览 31
已采纳

如果用户输入的数据不正确,应用程序必须重复提问

everyone! I'm newbie in Golang and I've a problem. I've some code like this (just example):

fmt.Println("yes or no:")
if _, err := fmt.Scan(&str); err != nil {
    panic(err)
}
if str == "no" {
    fmt.Println("You have to enter yes.")
    //What do I need to write this?
}

I wont it shows the question "yes or no" again til an user enters correct data or terminate proccess.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题