The function should return (using n) the bytes written by each writer with index position corresponding to the index position of the writer.

technical writing

Description

- implement a WriteTo function that writes to multiple writers.

1. Write the []byte slice to all writers.
2. The function should return (using n) the bytes written by each writer with index position corresponding to the index position of the writer. An empty slice ([]int{}) should be returned if there are no writers as argument to the function.

3. If one of the writers returned an error, that error should be returned in the index position corresponding to the index position of the writer.
4. If one of the writers could not write the entire buffer, the error
io.ErrShortWrite should be returned in the index position corresponding to
that writer's index position.

5. If no errors were observed, the function must return n, nil.

func WriteTo(b []byte, writers ...io.Writer) (n []int, errs Errors) {
return []int{}, nil
}


Related Questions in technical writing category