Use scanner instead of buffer read line
Supported in Go 1.1 http://golang.org/pkg/bufio/#Scanner
This commit is contained in:
parent
56cf1e6faa
commit
6da9a2d49d
|
@ -245,12 +245,11 @@ func retryFunc(timeout time.Duration, f func() error) error {
|
||||||
// of a remote command to log output for users.
|
// of a remote command to log output for users.
|
||||||
func streamLogs(r io.ReadCloser, name string) {
|
func streamLogs(r io.ReadCloser, name string) {
|
||||||
defer r.Close()
|
defer r.Close()
|
||||||
bufR := bufio.NewReader(r)
|
scanner := bufio.NewScanner(r)
|
||||||
for {
|
for scanner.Scan() {
|
||||||
line, err := bufR.ReadString('\n')
|
log.Printf("remote-exec: %s: %s", name, scanner.Text())
|
||||||
if err != nil {
|
}
|
||||||
|
if err := scanner.Err(); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Printf("remote-exec: %s: %s", name, line)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue