This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package backup_downloader | |
import ( | |
"bytes" | |
"io" | |
"log" | |
"os" | |
"os/exec" | |
"sync" | |
) | |
func decompressLzopPipe(decompressed_out io.Writer) (*io.PipeWriter, *sync.WaitGroup) { | |
reader, writer := io.Pipe() | |
cmd := exec.Command("lzop", "-d") | |
var wg sync.WaitGroup | |
wg.Add(1) | |
go func() { | |
var out bytes.Buffer // We save the stdout and print it if there is an error | |
cmd.Stdin = reader | |
cmd.Stdout = decompressed_out | |
cmd.Stderr = &out | |
err := cmd.Run() | |
if err != nil { | |
io.Copy(os.Stdout, io.Reader(&out)) | |
log.Fatal(err) | |
} | |
wg.Done() | |
}() | |
return writer, &wg | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment