Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: empty string when new newline at the end of stdin (#96)
The code reads the token from `stdin` until newline. If there is no newline, it counts the content as empty string. We use `bufio.NewReader` with `reader.ReadString('\n')` which "reads until the first occurrence of delim in the input". When it can't find a newline character before the stream ends we return with an error and an empty string. Fix: As `reader.ReadString` returns with the content before the error in all cases, we can return with the content even if we meet an error. Note: We should check if the error was EOF on caller side everywhere. Fixes #95 References: * #95 Signed-off-by: Efertone <[email protected]>
- Loading branch information