MCPcopy Index your code
hub / github.com/nikivdev/go / resolveOpenAIKey

Function resolveOpenAIKey

cli/flow/main.go:2872–2883  ·  view source on GitHub ↗

resolveOpenAIKey attempts to find an OpenAI key quickly without extra config. resolveOpenAIKey reads the key from OPENAI_API_KEY and caches it for reuse.

(context.Context)

Source from the content-addressed store, hash-verified

2870// resolveOpenAIKey attempts to find an OpenAI key quickly without extra config.
2871// resolveOpenAIKey reads the key from OPENAI_API_KEY and caches it for reuse.
2872func resolveOpenAIKey(context.Context) (string, error) {
2873 if key := strings.TrimSpace(os.Getenv(openAIAPIKeyEnv)); key != "" {
2874 cachedOpenAIKey = key
2875 return key, nil
2876 }
2877
2878 if cachedOpenAIKey != "" {
2879 return cachedOpenAIKey, nil
2880 }
2881
2882 return "", fmt.Errorf("%s is not set; export it before running %s commit", openAIAPIKeyEnv, commandName)
2883}
2884
2885func reportError(ctx *snap.Context, err error) error {
2886 if err == nil {

Callers 1

prepareCommitFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected