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.
This commit is contained in:
Ross Golder
2026-08-10 17:00:17 +02:00
committed by GitHub
parent ddbabd87ed
commit 7a064d66a4
+1 -1
View File
@@ -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()))
}