util.go 310 B

12345678910111213141516171819202122
  1. package control
  2. import (
  3. "bufio"
  4. "fmt"
  5. "os"
  6. "strings"
  7. "github.com/rancher/os/log"
  8. )
  9. func yes(question string) bool {
  10. fmt.Printf("%s [y/N]: ", question)
  11. in := bufio.NewReader(os.Stdin)
  12. line, err := in.ReadString('\n')
  13. if err != nil {
  14. log.Fatal(err)
  15. }
  16. return strings.ToLower(line[0:1]) == "y"
  17. }