readLine reads up to a newline from in. Used only on the interactive confirmation path; bounded read so we don't hang on a closed stdin.
(in io.Reader)
| 649 | // readLine reads up to a newline from in. Used only on the interactive |
| 650 | // confirmation path; bounded read so we don't hang on a closed stdin. |
| 651 | func readLine(in io.Reader) string { |
| 652 | buf := make([]byte, 0, 64) |
| 653 | one := make([]byte, 1) |
| 654 | for { |
| 655 | n, err := in.Read(one) |
| 656 | if n == 0 || err != nil { |
| 657 | break |
| 658 | } |
| 659 | if one[0] == '\n' { |
| 660 | break |
| 661 | } |
| 662 | buf = append(buf, one[0]) |
| 663 | if len(buf) > 1024 { |
| 664 | break |
| 665 | } |
| 666 | } |
| 667 | return string(buf) |
| 668 | } |
| 669 | |
| 670 | // keepSortedNamesUsed is a compile-time guard against accidental dead |
| 671 | // imports while iterating on the file. sort is referenced via this helper. |
no outgoing calls
no test coverage detected