1 개요[ | ]
- Go confirm()
Go
Copy
package main
import (
"fmt"
"log"
"regexp"
)
func confirm() bool {
var response string
_, err := fmt.Scanln(&response)
if err != nil {
log.Fatal(err)
}
match, _ := regexp.MatchString("[yY][eE][sS]|[yY]", response)
return match
}
func main() {
fmt.Print("Are you sure you want to do this? [y/N] ")
isYes := confirm()
fmt.Println("isYes=", isYes)
}
2 같이 보기[ | ]
편집자 Jmnote
로그인하시면 댓글을 쓸 수 있습니다.