1
0
mirror of https://github.com/lxc/incus.git synced 2026-02-05 09:46:19 +01:00
Files
incus/internal/io/writer.go
Denys Mosiiuk f0c4438e70 incus/io: #2636 fix linter complaints in internal/io
Changes:

  - Added missing docstrings.
  - Renamed `min` function parameter to `minimum`.

Signed-off-by: Denys Mosiiuk <dmos@dector.space>
2025-12-15 23:32:15 +01:00

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
}
}
}