ReadString reads one line from the given io.Reader.
(r io.Reader)
| 42 | |
| 43 | // ReadString reads one line from the given io.Reader. |
| 44 | func ReadString(r io.Reader) (string, error) { |
| 45 | br := bufio.NewReader(r) |
| 46 | str, err := br.ReadString('\n') |
| 47 | if err != nil && err != io.EOF { |
| 48 | return "", errors.Wrap(err, "error reading string") |
| 49 | } |
| 50 | return strings.TrimSpace(str), nil |
| 51 | } |
| 52 | |
| 53 | // ReadPasswordFromFile reads and returns the password from the given filename. |
| 54 | // The contents of the file will be trimmed at the right. |
no outgoing calls
searching dependent graphs…