From 0ca908f434f354ce43d2ac840f98a0a1b68e030f Mon Sep 17 00:00:00 2001 From: Snider Date: Mon, 3 Nov 2025 00:13:13 +0000 Subject: [PATCH] style: format code for consistency and readability --- pkg/crypt/crypt.go | 2 +- pkg/crypt/crypt_test.go | 9 ++++----- pkg/crypt/std/rsa/rsa.go | 2 +- pkg/trix/trix.go | 4 ++-- pkg/trix/trix_test.go | 8 ++++---- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/pkg/crypt/crypt.go b/pkg/crypt/crypt.go index 7bb6d09..6591fba 100644 --- a/pkg/crypt/crypt.go +++ b/pkg/crypt/crypt.go @@ -160,4 +160,4 @@ func (s *Service) EncryptRSA(publicKey, data, label []byte) ([]byte, error) { func (s *Service) DecryptRSA(privateKey, ciphertext, label []byte) ([]byte, error) { s.ensureRSA() return s.rsa.Decrypt(privateKey, ciphertext, label) -} \ No newline at end of file +} diff --git a/pkg/crypt/crypt_test.go b/pkg/crypt/crypt_test.go index a8e2bff..1c0d6b3 100644 --- a/pkg/crypt/crypt_test.go +++ b/pkg/crypt/crypt_test.go @@ -31,11 +31,11 @@ func TestHash_Bad(t *testing.T) { func TestHash_Ugly(t *testing.T) { // Test with potentially problematic inputs testCases := []string{ - "", // Empty string - " ", // Whitespace - "\x00\x01\x02\x03\x04", // Null bytes + "", // Empty string + " ", // Whitespace + "\x00\x01\x02\x03\x04", // Null bytes strings.Repeat("a", 1024*1024), // Large payload (1MB) - "こんにちは", // Unicode characters + "こんにちは", // Unicode characters } for _, tc := range testCases { @@ -105,7 +105,6 @@ func TestFletcher64_Ugly(t *testing.T) { assert.NotEqual(t, uint64(0), service.Fletcher64("abc"), "Checksum of length 3 string") } - // --- RSA Tests --- func TestRSA_Good(t *testing.T) { diff --git a/pkg/crypt/std/rsa/rsa.go b/pkg/crypt/std/rsa/rsa.go index 5a19d3a..5470ea8 100644 --- a/pkg/crypt/std/rsa/rsa.go +++ b/pkg/crypt/std/rsa/rsa.go @@ -88,4 +88,4 @@ func (s *Service) Decrypt(privateKey, ciphertext, label []byte) ([]byte, error) } return plaintext, nil -} \ No newline at end of file +} diff --git a/pkg/trix/trix.go b/pkg/trix/trix.go index 61c88d7..1cac073 100644 --- a/pkg/trix/trix.go +++ b/pkg/trix/trix.go @@ -30,8 +30,8 @@ var ( type Trix struct { Header map[string]interface{} Payload []byte - InSigils []string `json:"-"` // Ignore Sigils during JSON marshaling - OutSigils []string `json:"-"` // Ignore Sigils during JSON marshaling + InSigils []string `json:"-"` // Ignore Sigils during JSON marshaling + OutSigils []string `json:"-"` // Ignore Sigils during JSON marshaling ChecksumAlgo crypt.HashType `json:"-"` } diff --git a/pkg/trix/trix_test.go b/pkg/trix/trix_test.go index d0a9cec..4d52ed3 100644 --- a/pkg/trix/trix_test.go +++ b/pkg/trix/trix_test.go @@ -85,10 +85,10 @@ func TestTrixEncodeDecode_Ugly(t *testing.T) { t.Run("CorruptedHeaderLength", func(t *testing.T) { // Manually construct a byte slice where the header length is larger than the actual data. var buf []byte - buf = append(buf, []byte(magicNumber)...) // Magic Number - buf = append(buf, byte(trix.Version)) // Version - buf = append(buf, []byte{0, 0, 3, 232}...) // BigEndian representation of 1000 - buf = append(buf, []byte("{}")...) // A minimal valid JSON header + buf = append(buf, []byte(magicNumber)...) // Magic Number + buf = append(buf, byte(trix.Version)) // Version + buf = append(buf, []byte{0, 0, 3, 232}...) // BigEndian representation of 1000 + buf = append(buf, []byte("{}")...) // A minimal valid JSON header buf = append(buf, []byte("payload")...) _, err := trix.Decode(buf, magicNumber)