aboutsummaryrefslogtreecommitdiff
path: root/ReadByte.go
blob: 75f843bf31c903dc93e8e3e2faf28b1a5cb9716a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package kagus

import (
	"io"
)

// ReadByte reads a single byte from a reader
func ReadByte(r io.Reader) (byte, error) {
	buf := make([]byte, 1)

	for {
		n, err := r.Read(buf)
		if n == 1 {
			break
		}

		if err != nil {
			return 0, err
		}
	}

	return buf[0], nil
}