Hi, thanks for the tip.
But still i feel like there s a kind of mental gymnastic to apply which remains unfriendly package main import ( "os" "io" "compress/gzip" ) func main () { pr, pw := io.Pipe() go func () { decoder, _ := gzip.NewReader(pr) io.Copy(os.Stdout, decoder) }() archiver := gzip.NewWriter(pw) defer archiver.Close() io.Copy(archiver, os.Stdin) } Here i start with a through, then i go func it to a sink, next i create a transform and finally copy src to the preceding transform. I feel like i m playing the mega mumble jumble in and out of the stream. I would not like to have too much transforms : ( just pocking around this, i d like very much to see something like this from the core, I honestly admit i have no real understanding of what i m doing (1 day maybe i ll get it) package main import ( "fmt" "os" // "bytes" // "encoding/base64" "github.com/mh-cbon/stream/stream3" ) func main () { // src, _ := os.Open("main.go") stdin := os.Stdin s := stream.CreateStreamReader(stdin) // s.Pipe(stream.B64Encode(base64.StdEncoding)).Pipe(stream.CreateStreamWriter(os.Stdout)) s.Pipe(stream.GzipEncode()).Pipe(stream.GzipDecode()).Pipe(stream. CreateStreamWriter(os.Stdout)) err := s.Consume() if err!=nil { fmt.Println(err) } stdin.Close() } I can only figure out it works on the other end :o But its way more readable, to me, src -> transform -> transform -> sink Le mardi 28 juin 2016 21:51:19 UTC+2, Tamás Gulácsi a écrit : > > Don't forget io.Pipe: an easy way to transform a Reader to a Writer, or > vice versa, if that makes it easier. > For example read in a loop into a big, replace as you wish, and write the > result to a pipe. And return the reader pair of the pipe. > This way you don't have to account the reader's buffering. -- 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.