hayai/vendor/github.com/mewkiz/flac/internal/ioutilx/byte.go
2024-12-21 17:26:50 +01:00

25 lines
489 B
Go

// Package ioutilx implements extended input/output utility functions.
package ioutilx
import (
"io"
)
// ReadByte reads and returns the next byte from r.
func ReadByte(r io.Reader) (byte, error) {
var buf [1]byte
if _, err := io.ReadFull(r, buf[:]); err != nil {
return 0, err
}
return buf[0], nil
}
// WriteByte writes the given byte to w.
func WriteByte(w io.Writer, b byte) error {
buf := [1]byte{b}
if _, err := w.Write(buf[:]); err != nil {
return err
}
return nil
}