Skip to content

Instantly share code, notes, and snippets.

@tenntenn
Last active December 10, 2015 04:08
Show Gist options
  • Save tenntenn/4379518 to your computer and use it in GitHub Desktop.
Save tenntenn/4379518 to your computer and use it in GitHub Desktop.
func input(ans chan int) {
r := bufio.NewReader(os.Stdin)
for {
line, _, err := r.ReadLine()
if err != nil {
fmt.Print(">")
continue
}
str := strings.Replace(string(line), "\r", "", -1)
n, err := strconv.Atoi(str)
if err != nil {
fmt.Print(">")
continue
}
ans <- n
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment