mirror of
https://github.com/lxc/incus.git
synced 2026-02-05 09:46:19 +01:00
Changes: - Added missing docstrings. - Renamed `min` function parameter to `minimum`. Signed-off-by: Denys Mosiiuk <dmos@dector.space>
25 lines
333 B
Go
25 lines
333 B
Go
package io
|
|
|
|
import (
|
|
"bytes"
|
|
"io"
|
|
)
|
|
|
|
// WriteAll copies content of data to specified writer.
|
|
func WriteAll(w io.Writer, data []byte) error {
|
|
buf := bytes.NewBuffer(data)
|
|
|
|
toWrite := int64(buf.Len())
|
|
for {
|
|
n, err := io.Copy(w, buf)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
toWrite -= n
|
|
if toWrite <= 0 {
|
|
return nil
|
|
}
|
|
}
|
|
}
|