From 69e9926bcc9f766aef5cb34babd94ef627337835 Mon Sep 17 00:00:00 2001 From: chuangjinglu Date: Tue, 12 Nov 2024 22:41:18 +0800 Subject: [PATCH] fix: fix slice init length (#8707) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Which Problems Are Solved The intention here should be to initialize a slice with a capacity of len(queriedOrgs.Orgs) rather than initializing the length of this slice. the online demo: https://go.dev/play/p/vNUPNjdb2gJ # How the Problems Are Solved use `processedOrgs := make([]string, 0, len(queriedOrgs.Orgs))` # Additional Changes None # Additional Context None Co-authored-by: Tim Möhlmann --- internal/api/grpc/admin/export.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/api/grpc/admin/export.go b/internal/api/grpc/admin/export.go index 408a1a59fe..68b6053c2c 100644 --- a/internal/api/grpc/admin/export.go +++ b/internal/api/grpc/admin/export.go @@ -42,7 +42,7 @@ func (s *Server) ExportData(ctx context.Context, req *admin_pb.ExportDataRequest } orgs := make([]*admin_pb.DataOrg, len(queriedOrgs.Orgs)) - processedOrgs := make([]string, len(queriedOrgs.Orgs)) + processedOrgs := make([]string, 0, len(queriedOrgs.Orgs)) processedProjects := make([]string, 0) processedGrants := make([]string, 0) processedUsers := make([]string, 0)