From 5c4286f518da678f0173f9f274f893aae2843270 Mon Sep 17 00:00:00 2001 From: Amolith Date: Sun, 21 Dec 2025 15:01:36 -0700 Subject: [PATCH] chore: enable prealloc linter - Enable prealloc linter in golangci config - Preallocate slice capacity in Goals completion function Assisted-by: Claude Opus 4.5 via Amp --- .golangci.yaml | 1 + internal/completion/completion.go | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.golangci.yaml b/.golangci.yaml index 8b2211705bdb808e7b00736ec45aaae5971735c1..5bc1f83b89e57acda1d65416c08be1cb0c6cf7b7 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -114,6 +114,7 @@ linters: - wrapcheck - wsl_v5 - zerologlint + - prealloc disable: - depguard diff --git a/internal/completion/completion.go b/internal/completion/completion.go index 7f03746a00c4bc85295c760c7f1dd24f6b98be6f..9bab7ba7bd07121e33e0c7448e04b00fb94e12ee 100644 --- a/internal/completion/completion.go +++ b/internal/completion/completion.go @@ -32,7 +32,12 @@ func Goals(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDir return nil, cobra.ShellCompDirectiveError } - var keys []string + totalGoals := 0 + for _, a := range cfg.Areas { + totalGoals += len(a.Goals) + } + + keys := make([]string, 0, totalGoals) for _, a := range cfg.Areas { for _, g := range a.Goals {