mirror of
https://github.com/fiatjaf/nak.git
synced 2024-11-22 16:19:07 -05:00
ensure at least one blank line will be emitted when piped.
This commit is contained in:
parent
6626001dd2
commit
e89823b10e
|
@ -69,8 +69,13 @@ func writeStdinLinesOrNothing(ch chan string) (hasStdinLines bool) {
|
||||||
go func() {
|
go func() {
|
||||||
scanner := bufio.NewScanner(os.Stdin)
|
scanner := bufio.NewScanner(os.Stdin)
|
||||||
scanner.Buffer(make([]byte, 16*1024), 256*1024)
|
scanner.Buffer(make([]byte, 16*1024), 256*1024)
|
||||||
|
hasEmittedAtLeastOne := false
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
ch <- strings.TrimSpace(scanner.Text())
|
ch <- strings.TrimSpace(scanner.Text())
|
||||||
|
hasEmittedAtLeastOne = true
|
||||||
|
}
|
||||||
|
if !hasEmittedAtLeastOne {
|
||||||
|
ch <- ""
|
||||||
}
|
}
|
||||||
close(ch)
|
close(ch)
|
||||||
}()
|
}()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user