On 6 June 2012 19:17, Vasiliy Tolstov <
v.to...@selfip.ru> wrote:
> Hello. I'm try to use io.MultiWriter via writing to local cache file
> and http.WriteCloser, but in source file of multiwriter function each
> writer not run in parallel, why?
> For example if the http client has poor network speed writing to local
> file may be delayed. If the local fs is slowdown - writing to client
> may be delayed...
>
> Who not spawn for each writer new goroutine?
io.MultiWriter is a simple primitive whose behavior easy to understand.
An implementation like the one you describe would need to buffer data
for the slower writer, and wouldn't be able to return a write error if
a buffered write failed. There are a lot of questions about how such a
thing should be designed, and their answers depend a lot on how they
are used.
Fortunately, Go's concurrency features make it pretty easy to write
the multiwriter that you need, depending on your particular use.
Andrew