Created
February 18, 2017 23:09
-
-
Save ifukazoo/db448ddda18c19d3e39e059ef9743b58 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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