Skip to content

Instantly share code, notes, and snippets.

@ifukazoo
Created February 18, 2017 23:09
Show Gist options
  • Select an option

  • Save ifukazoo/db448ddda18c19d3e39e059ef9743b58 to your computer and use it in GitHub Desktop.

Select an option

Save ifukazoo/db448ddda18c19d3e39e059ef9743b58 to your computer and use it in GitHub Desktop.
package egetline
import (
"bufio"
"os"
)
var scanner *bufio.Scanner
func init() {
scanner = bufio.NewScanner(os.Stdin)
}
// EGetLine 1行取得する
// 失敗:exit()
// EOF:true
func EGetLine() (string, bool) {
if !scanner.Scan() {
if err := scanner.Err(); err != nil {
os.Exit(1)
}
return "", true
}
return scanner.Text(), false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment