How to pipe stdout for os.Exec to file but also to terminal?
I've try this:
go func() {
scanner := bufio.NewScanner(stdout)
writer := bufio.NewWriter(logFile)
for scanner.Scan() {
log.Debugln(scanner.Text())
writer.WriteString(scanner.Text())
}
writer.Flush()
}()
But writer.WriteString(scanner.Text())
losts
in file. How to got them back? Maybe there is some more elegant solution with pipes?