Skip to content

Instantly share code, notes, and snippets.

@leejarvis
Created August 15, 2012 11:23
Show Gist options
  • Save leejarvis/3359291 to your computer and use it in GitHub Desktop.
Save leejarvis/3359291 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"bufio"
"os"
"strings"
)
func askYes(question string) (answer string, ok bool) {
reader := bufio.NewReader(os.Stdin)
fmt.Print(question, ": ")
answer, _ = reader.ReadString('\n')
answer = strings.ToLower(strings.TrimRight(answer, "\n"))
ok = answer[0] == 'y'
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment