env

package
v0.19.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package env provides per-request environment variable lookup that avoids mutating the process environment.

The daemon serves multiple concurrent client requests in the same process. Forwarding client env vars by mutating os.Environ would either require a process-wide mutex held across cmd.Execute() (which serialises all command execution) or risk cross-request contamination (one client's env value leaking into another client's command).

Instead, the daemon attaches a per-request env map to the cobra command's context and code that previously called os.Getenv now calls env.Lookup(ctx, key). The lookup falls back to os.Getenv when no per-request map is present so direct CLI invocations behave normally.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Lookup

func Lookup(ctx context.Context, key string) string

Lookup returns the value for key, preferring the per-request env map stored on ctx and falling back to the process environment.

func WithEnv

func WithEnv(ctx context.Context, env map[string]string) context.Context

WithEnv returns ctx augmented with the given env map. The map is looked up first by Lookup before falling back to os.Getenv.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL