File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -61,12 +61,15 @@ func main() {
6161
6262 // Read from Stdin and log it to Stdout and Stackdriver
6363 lines := make (chan string )
64- s := bufio .NewScanner (io .TeeReader (os .Stdin , os .Stdout ))
6564 go func () {
66- defer close ( lines )
65+ s := bufio . NewScanner ( io . TeeReader ( os . Stdin , os . Stdout ) )
6766 for s .Scan () {
6867 lines <- s .Text ()
6968 }
69+ if err := s .Err (); err != nil {
70+ errc <- fmt .Errorf ("could not read from std in: %v" , err )
71+ }
72+ close (lines )
7073 }()
7174
7275 signals := make (chan os.Signal )
@@ -95,9 +98,5 @@ mainLoop:
9598 log .Fatalf ("Failed to close client: %v" , err )
9699 }
97100
98- if err := s .Err (); err != nil {
99- log .Fatalf ("Failed to scan input: %v" , err )
100- }
101-
102101 fmt .Fprintln (os .Stderr , "Finished logging" )
103102}
You can’t perform that action at this time.
0 commit comments