From 307d1aec4440c9605c2b753ea060ed0addd49dd4 Mon Sep 17 00:00:00 2001 From: "Sascha L. Teichmann" Date: Sun, 24 Aug 2014 19:40:57 +0200 Subject: [PATCH] interleaver: Do not share error in producer and consumer. --- interleaver/main.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/interleaver/main.go b/interleaver/main.go index 9efbf98..9c61b26 100644 --- a/interleaver/main.go +++ b/interleaver/main.go @@ -48,7 +48,7 @@ func selectKeyEncoder(interleaved bool) common.KeyEncoder { return common.EncodeStringToBytes } -func copyProducerToConsumer(producer BlockProducer, consumer BlockConsumer) (err error) { +func copyProducerToConsumer(producer BlockProducer, consumer BlockConsumer) error { blocks := make(chan *Block) done := make(chan struct{}) @@ -58,7 +58,7 @@ func copyProducerToConsumer(producer BlockProducer, consumer BlockConsumer) (err defer close(blocks) for { block := new(Block) - if err = producer.Next(block); err != nil { + if err := producer.Next(block); err != nil { if err != ErrNoMoreBlocks { log.Printf("Reading failed: %s\n", err) } @@ -74,8 +74,8 @@ func copyProducerToConsumer(producer BlockProducer, consumer BlockConsumer) (err i := 0 for block := range blocks { - if err = consumer.Consume(block); err != nil { - return + if err := consumer.Consume(block); err != nil { + return err } i++ if i%1000 == 0 { @@ -84,7 +84,7 @@ func copyProducerToConsumer(producer BlockProducer, consumer BlockConsumer) (err } log.Printf("%d blocks transferred in total.\n", i) - return + return nil } func main() {