From ce98671449dc3bb6d7a53144fea25954e9df6192 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Bajpai Date: Tue, 21 Jul 2026 12:09:31 +0530 Subject: [PATCH] fix: initialize entries slice in NewTransferHistory NewTransferHistory did not initialize the entries slice, leaving it nil. While the Add function handled nil entries lazily, initializing in the constructor is safer and follows Go best practices. --- beamsync/history.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/beamsync/history.go b/beamsync/history.go index 769beaf..9018db3 100644 --- a/beamsync/history.go +++ b/beamsync/history.go @@ -43,7 +43,10 @@ func NewTransferHistory(maxEntries int) *TransferHistory { if maxEntries <= 0 { maxEntries = defaultTransferHistoryLimit } - return &TransferHistory{maxEntries: maxEntries} + return &TransferHistory{ + maxEntries: maxEntries, + entries: make([]TransferRecord, maxEntries), + } } func (h *TransferHistory) Add(record TransferRecord) TransferRecord {