aboutsummaryrefslogtreecommitdiff
path: root/ReadByte.go
diff options
context:
space:
mode:
Diffstat (limited to 'ReadByte.go')
-rw-r--r--ReadByte.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/ReadByte.go b/ReadByte.go
new file mode 100644
index 0000000..75f843b
--- /dev/null
+++ b/ReadByte.go
@@ -0,0 +1,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
+}