From 5342cfec63682f886635485cbe6ad8d40077a4e6 Mon Sep 17 00:00:00 2001 From: mykola2312 <49044616+mykola2312@users.noreply.github.com> Date: Sun, 29 Dec 2024 12:29:07 +0200 Subject: [PATCH] refactor package naming --- crypto/lux_key.go | 6 +++--- types/lux_data.go => proto/lux_buffer.go | 2 +- proto/lux_data.go | 6 ++++++ {types => proto}/lux_type.go | 2 +- tests/{lux_data_test.go => lux_buffer_test.go} | 8 ++++---- 5 files changed, 15 insertions(+), 9 deletions(-) rename types/lux_data.go => proto/lux_buffer.go (99%) create mode 100644 proto/lux_data.go rename {types => proto}/lux_type.go (81%) rename tests/{lux_data_test.go => lux_buffer_test.go} (90%) diff --git a/crypto/lux_key.go b/crypto/lux_key.go index dc24e0a..a42ce31 100644 --- a/crypto/lux_key.go +++ b/crypto/lux_key.go @@ -2,18 +2,18 @@ package crypto import ( "crypto/rand" - "lux/types" + "lux/proto" "github.com/google/uuid" ) type LuxKey struct { - Type types.LuxType + Type proto.LuxType Id uuid.UUID Key []byte } -func (key *LuxKey) NewLuxKey(keyType types.LuxType) error { +func (key *LuxKey) NewLuxKey(keyType proto.LuxType) error { key.Type = keyType key.Id = uuid.New() key.Key = make([]byte, 32) diff --git a/types/lux_data.go b/proto/lux_buffer.go similarity index 99% rename from types/lux_data.go rename to proto/lux_buffer.go index b019e27..86d5f30 100644 --- a/types/lux_data.go +++ b/proto/lux_buffer.go @@ -1,4 +1,4 @@ -package types +package proto import ( "encoding/binary" diff --git a/proto/lux_data.go b/proto/lux_data.go new file mode 100644 index 0000000..952c76a --- /dev/null +++ b/proto/lux_data.go @@ -0,0 +1,6 @@ +package proto + +type LuxData interface { + Read(rd *LuxBuffer) error + Write(wd *LuxBuffer) error +} diff --git a/types/lux_type.go b/proto/lux_type.go similarity index 81% rename from types/lux_type.go rename to proto/lux_type.go index 95e5e00..ccb7823 100644 --- a/types/lux_type.go +++ b/proto/lux_type.go @@ -1,4 +1,4 @@ -package types +package proto type LuxType uint diff --git a/tests/lux_data_test.go b/tests/lux_buffer_test.go similarity index 90% rename from tests/lux_data_test.go rename to tests/lux_buffer_test.go index 92e6570..00c361f 100644 --- a/tests/lux_data_test.go +++ b/tests/lux_buffer_test.go @@ -2,7 +2,7 @@ package tests import ( "bytes" - "lux/types" + "lux/proto" "testing" ) @@ -10,7 +10,7 @@ func TestWriteGrow(t *testing.T) { first, second := []byte{1, 2, 3, 4}, []byte{5, 6, 7, 8} must := []byte{1, 2, 3, 4, 5, 6, 7, 8} - buf := types.AllocLuxBuffer(4) + buf := proto.AllocLuxBuffer(4) buf.WriteBytes(first) t.Log(buf.AllBytes()) @@ -23,7 +23,7 @@ func TestWriteGrow(t *testing.T) { } func TestInts(t *testing.T) { - wd := types.AllocLuxBuffer(1) + wd := proto.AllocLuxBuffer(1) wd.WriteUint16(1234) wd.WriteUint16(4321) wd.WriteUint64(69) @@ -44,7 +44,7 @@ func TestInts(t *testing.T) { } func TestStrings(t *testing.T) { - wd := types.AllocLuxBuffer(1) + wd := proto.AllocLuxBuffer(1) wd.WriteString("a") // 4 wd.WriteString("hello") // 8