From 4fe8f08bac9ab39e08414ff90e6f28b21f006926 Mon Sep 17 00:00:00 2001 From: Chris Gianelloni Date: Sun, 10 Nov 2024 22:05:18 -0500 Subject: [PATCH] fix: assign variables to prevent slicing into nil (#28) Signed-off-by: Chris Gianelloni --- branch.go | 2 +- trie_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/branch.go b/branch.go index 3a276d5..a5d644f 100644 --- a/branch.go +++ b/branch.go @@ -281,7 +281,7 @@ func (b *Branch) generateProof(path []Nibble) (*Proof, error) { } func (b *Branch) getChildren() []Node { - var ret []Node + ret := []Node{} for _, tmpChild := range b.children { if tmpChild != nil { ret = append(ret, tmpChild) diff --git a/trie_test.go b/trie_test.go index 5f9fca0..0d08725 100644 --- a/trie_test.go +++ b/trie_test.go @@ -233,7 +233,7 @@ func TestTrieFruitsGet(t *testing.T) { func TestTrieFruitsSetDeleteConsistentHash(t *testing.T) { trie := NewTrie() - var hashes []Hash + hashes := []Hash{} for _, entry := range fruitsTestEntries { hashes = append(hashes, trie.Hash()) trie.Set([]byte(entry.key), []byte(entry.value))