Reputation: 33
I need Create MultiReader of slice []*bytes.Buffer
buffer_slice := ... (type []*bytes.Buffer)
When i write io.MultiReader(buffer_slice)
I get the error:
cannot use buffer_slice (type []*bytes.Buffer) as type io.Reader in argument to io.MultiReader: []*bytes.Buffer does not implement io.Reader (missing Read method).
But function signature MultiReader(readers ...Reader) Reader
I understand that the transmit array is meaningless, the actual question: besides the trivial cycle, there are no more options?
P.S. Sorry for my bad english.
Upvotes: 3
Views: 2002
Reputation: 12320
Your slice should be type []io.Reader
b1 := &bytes.Buffer{}
b2 := &bytes.Buffer{}
buffers := []io.Reader{b1, b2}
multi := io.MultiReader(buffers...)
Upvotes: 4