mirror of
https://github.com/make-42/hayai.git
synced 2025-01-19 10:57:33 +01:00
25 lines
489 B
Go
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
|
||
|
}
|