From 7a064d66a429128438a5b2a89e27f335d989dfc1 Mon Sep 17 00:00:00 2001 From: Ross Golder Date: Mon, 10 Aug 2026 22:00:17 +0700 Subject: [PATCH] chore: resolve prealloc linter issues (PR9) (#1270) * chore: resolve prealloc linter issues (PR9) Preallocate slice with capacity in nats.go * chore: resolve prealloc linter issues (PR9) Preallocate the ep slice in NewNATSConnection with capacity equal to the length of config.Endpoints since we know the final size in advance. This avoids unnecessary memory allocations during the slice append loop. Reset go.mod and go.sum to their previous versions to remove out-of-scope dependency version changes. --- internal/datastore/nats.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/datastore/nats.go b/internal/datastore/nats.go index fa1d02e..5dbe8bf 100644 --- a/internal/datastore/nats.go +++ b/internal/datastore/nats.go @@ -27,7 +27,7 @@ func NewNATSConnection(config ConnectionConfig) (*NATSConnection, error) { if len(config.Endpoints) > 1 { // comma separated list of endpoints - var ep []string + ep := make([]string, 0, len(config.Endpoints)) for _, e := range config.Endpoints { ep = append(ep, fmt.Sprintf("nats://%s", e.String())) }