From 1b25deb818abd5de812ae729149b71c90aa35c0e Mon Sep 17 00:00:00 2001 From: shoopea Date: Sun, 14 Jun 2020 17:12:58 +0200 Subject: [PATCH] test --- def.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/def.go b/def.go index e055f52..1e5b06a 100644 --- a/def.go +++ b/def.go @@ -51,15 +51,18 @@ type Packet struct { type PacketAdminJoin struct { Packet - Password []byte - AppName []byte - AppVersion []byte + Password string + AppName string + AppVersion string } func (p *PacketAdminJoin) Bytes() []byte { buf := new(bytes.Buffer) - p.PLength = uint16(binary.Size(p)) - err := binary.Write(buf, binary.LittleEndian, p) - logErrorDebug(err, "binary.Write") + enc := gob.NewEncoder(&buf) + + p.PLength = uint16(len(p.Password) + len(p.AppName) + len(p.AppVersion) + 3) + err := enc.Encode(p) + logErrorDebug(err, "enc.Encode") + return buf.Bytes() }