aboutsummaryrefslogtreecommitdiff
path: root/hotline/util.go
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2023-01-18 13:56:30 -0800
committerGitHub <noreply@github.com>2023-01-18 13:56:30 -0800
commit3bdabf7a43a9bccb61557f22bba725c9b4334e0c (patch)
treea1ebb95925e3834371e1aeb82002ce033441284f /hotline/util.go
parentfd5eb3ab478559a722976c8093a4c2c281019c45 (diff)
parent3326539367dfa85cb2b0455d5b1c67eaaf59cf8e (diff)
Merge pull request #88 from jhalter/fix_news_compatability_issues
Fix threaded news bugs
Diffstat (limited to 'hotline/util.go')
-rw-r--r--hotline/util.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/hotline/util.go b/hotline/util.go
new file mode 100644
index 0000000..d37feb5
--- /dev/null
+++ b/hotline/util.go
@@ -0,0 +1,17 @@
+package hotline
+
+import (
+ "encoding/binary"
+ "errors"
+)
+
+func byteToInt(bytes []byte) (int, error) {
+ switch len(bytes) {
+ case 2:
+ return int(binary.BigEndian.Uint16(bytes)), nil
+ case 4:
+ return int(binary.BigEndian.Uint32(bytes)), nil
+ }
+
+ return 0, errors.New("unknown byte length")
+}