[go] Honor empty ClientOptions.Env#297
Merged
friggeri merged 2 commits intogithub:mainfrom Jan 30, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Go SDK's handling of the ClientOptions.Env field to properly distinguish between an unset environment (nil) and an explicitly empty environment ([]string{}). When Env is nil, the client now captures the current process's environment variables at client creation time. When Env is an empty slice, the spawned CLI process receives no environment variables.
Changes:
- Updated documentation for the
Envfield inClientOptionsto clarify behavior for nil vs empty slice - Modified
NewClientto capture environment variables whenEnvis nil (at client creation time) - Simplified
startCLIServerto always usec.options.Envwithout additional conditional logic - Added comprehensive tests to verify nil, empty, and custom environment handling
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| go/types.go | Enhanced documentation for the Env field to clarify nil vs empty slice behavior, following Go's exec.Cmd conventions |
| go/client.go | Modified NewClient to capture environment at client creation when Env is nil; simplified startCLIServer to unconditionally use c.options.Env |
| go/client_test.go | Added TestClient_EnvOptions with three test cases covering custom environment, default inheritance, and empty environment scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
friggeri
approved these changes
Jan 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If a users creates a client with
ClientOptions{Env: []string{}}it expects that the CLI process does not inherit any variable from the current process.Also, if ClientOptions.Env is not set (aka nil), load the current process environment variables when creating the client instead of when starting the CLI process.
Both new behaviors are aligned with what a Go users expects and with the TypeScript SDK.