From a659fb06fa463c42dfd290ee32d1ba8693972dd4 Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Thu, 5 Dec 2024 16:58:03 +0300 Subject: [PATCH] Added a function to convert int to []byte --- common/db.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/db.go b/common/db.go index b1d67fd..80757e9 100644 --- a/common/db.go +++ b/common/db.go @@ -88,3 +88,10 @@ func (d DataTyp) ToBytes() []byte { binary.BigEndian.PutUint16(bytes, uint16(d)) return bytes } + +// Convert int to []byte +func IntToBytes(value int) []byte { + bytes := make([]byte, 2) + binary.BigEndian.PutUint16(bytes, uint16(value)) + return bytes +}