summaryrefslogtreecommitdiff
path: root/internal/llm/provider.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-23 08:27:18 +0200
committerPaul Buetow <paul@buetow.org>2026-03-23 08:27:18 +0200
commit3ea11bc5d671d962d01b57fa0fba0bda611025fe (patch)
tree4aa8c9d8a380a2a176a0a7302d07452a6996e2ef /internal/llm/provider.go
parent2d03ad0ba42bade8579578d12aecbf9a73d9af07 (diff)
fix: code quality improvements across lsp, askcli, appconfig, integrationtests
- lsp/handlers_completion.go: track collectFirstCompletion goroutine in inflight WaitGroup (goroutine leak fix) - lsp/transport.go: use %w instead of %v for error wrapping - askcli/command_list.go: extract handleListWithFilters shared helper; handleList/handleAll/handleReady are now single-liners - askcli/command_list.go, urgency.go, dep.go: log ParseTaskExport errors to stderr instead of returning 1 silently - appconfig/config_load.go: rename 'any' variable to 'found' to avoid shadowing the built-in identifier - llm/provider.go: add explanatory comment for package-level registry - integrationtests/ask_test.go: add //go:build integration tag; move repoRoot init from init() to TestMain with diagnostic error message Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/llm/provider.go')
-rw-r--r--internal/llm/provider.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/internal/llm/provider.go b/internal/llm/provider.go
index afc126b..3c72181 100644
--- a/internal/llm/provider.go
+++ b/internal/llm/provider.go
@@ -103,6 +103,14 @@ type ProviderKeys struct {
// ProviderFactory builds an LLM client for a named provider.
type ProviderFactory func(cfg Config, keys ProviderKeys) (Client, error)
+// providerRegistry is a package-level singleton populated by init() calls in
+// each provider file (anthropic.go, openai.go, etc.). It must be a
+// package-level var — rather than a constructor argument — because Go's
+// init() mechanism runs before any application code, and the alternative
+// (an explicit RegisterAll() in main) would require every binary that uses
+// the llm package to manually enumerate all providers. The RWMutex makes the
+// map safe for the rare case where RegisterProvider is called from a test
+// goroutine after init() has completed.
var (
providerRegistryMu sync.RWMutex
providerRegistry = map[string]ProviderFactory{}