Thanks for your reply.

After read your message, this are my test.

            cmd := exec.Command("mysqldump", args_mysqldump...)

            r, w := io.Pipe()

            z := zlib.NewWriter(w)
            defer z.Close()

            cmd.Stdout = z

            cmd.Start()

            uploader := s3manager.NewUploader(session.New(&aws.Config{Region
: aws.String(t.S3.AwsRegion)}))
            // Set default part size at 50MB
            uploader.PartSize = 104857600
            uploader.Upload(&s3manager.UploadInput{
                Body:   r,
                Bucket: aws.String(t.S3.Backet),
                Key:    aws.String(path.Join(t.S3.Prefix, file_name)),
            })

            done := make(chan error)
            go func() {
                done <- cmd.Wait()
            }()

but there is a problem, this stop in s3manager and never finish, but if I 
add go rutine in s3manager the program continue and finish without to do 
anything.
I dont know where is my mistake.

Well thanks in advance

Regards





El jueves, 13 de octubre de 2016, 15:20:22 (UTC-3), Konstantin Khomoutov 
escribió:
>
> On Thu, 13 Oct 2016 10:43:24 -0700 (PDT) 
> Walter Garcia <wal...@gmail.com <javascript:>> wrote: 
>
> > Im trying to test using zlib. 
> > 
> > In my test I need compress the Stdout from exec.Command to zlib and 
> > then send to io.reader to use in other service 
> > 
> > cmd := exec.Command("mysqldump", args...) 
> > ...... 
> > cmd.StdoutPipe() 
> > 
> > z := zlib.NewWriter( ... ) 
> > ..... 
> > z -> to -> io.reader 
> > 
> > Could you help me? 
>
> You can't do that directly because you can only write to io.Writer-s. 
> This is reasonable if you stop and think about it for a moment: an 
> io.Writer is a "push-style" interface -- you write something to 
> whatever is implementing it and block until that action happens; -- 
> conversely, io.Reader is a "pull-style" interface -- you read something 
> from a source and that blocks until the source is ready. 
>
> To glue a writer and a reader you need some intermediate "thing" which 
> would simultaneostly be a reader and a writer (!) -- so that it 
> satisfies both kinds of interfaces described above. 
>
> Such things are called "pipes" and Go provides at least two of them: 
>
> * io.Pipe is a pure-Go pipe; 
> * os.Pipe is a pipe provided by the underlying kernel. 
>
> The former is supposedly what you need. 
>
> Still note that to make 
>
>   z -> pipe -> io.reader 
>
> really work the "z" and the "io.reader" parts have to be in separate 
> goroutines otherwise they will block one another. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to