envutil

package
v0.17.18 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package envutil provides environment variable helpers with SPROUT_* prefix support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheDir added in v0.17.17

func CacheDir() (string, error)

CacheDir returns the sprout cache directory path (disposable, regenerable).

Resolution: $SPROUT_CACHE_DIR → $XDG_CACHE_HOME/sprout → $HOME/.cache/sprout.

func ConfigDir added in v0.17.17

func ConfigDir() (string, error)

ConfigDir returns the sprout configuration directory path.

Resolution: $SPROUT_CONFIG_DIR → $SPROUT_CONFIG (legacy alias) → $XDG_CONFIG_HOME/sprout → $HOME/.config/sprout.

$SPROUT_CONFIG continues to work as an alias so test isolation and configuration.NewTestManager keep functioning unchanged.

func DataDir added in v0.17.17

func DataDir() (string, error)

DataDir returns the sprout shared data directory path (regenerable artifacts like embeddings, models).

Resolution: $SPROUT_DATA_DIR → $XDG_DATA_HOME/sprout → $HOME/.local/share/sprout.

func GetConfigDir deprecated

func GetConfigDir() (string, error)

GetConfigDir returns the sprout configuration directory path.

Deprecated: use ConfigDir(). Retained for backward compatibility with callers that have not been migrated.

func GetEnv

func GetEnv(suffix string) string

GetEnv returns the value of os.Getenv("SPROUT_"+suffix), or "" if unset.

func GetEnvSimple

func GetEnvSimple(suffix string) string

GetEnvSimple checks SPROUT_* for a variable name suffix. E.g., GetEnvSimple("CONFIG") checks SPROUT_CONFIG.

func HasPrefix

func HasPrefix(name string) bool

HasPrefix checks if an env var name starts with SPROUT_.

func LookupEnv

func LookupEnv(suffix string) (string, bool)

LookupEnv checks SPROUT_*. Returns the value and whether it was found.

func ResolveColorPreference

func ResolveColorPreference(want bool) bool

ResolveColorPreference applies the no-color.org environment overrides to a caller-supplied preference. SP-048-4a.

Precedence (no-color.org-mandated):

  • NO_COLOR set to any non-empty value → colors OFF (always wins)
  • FORCE_COLOR set to any non-empty value → colors ON (unless NO_COLOR)
  • otherwise → caller's want value

Lives in pkg/envutil because pkg/console depends on pkg/configuration (transitively pkg/utils) so pkg/utils can't import pkg/console without creating a cycle. pkg/envutil is the existing zero-dependency leaf used for env-var helpers.

func SetEnv

func SetEnv(suffix, value string) error

SetEnv sets the SPROUT_* version of an env var.

func StateDir added in v0.17.17

func StateDir() (string, error)

StateDir returns the sprout state directory path (machine-generated, per-install, not portable).

Resolution: $SPROUT_STATE_DIR → $XDG_STATE_HOME/sprout → $HOME/.local/state/sprout.

func UnsetEnv

func UnsetEnv(suffix string)

UnsetEnv removes the SPROUT_* version of an env var.

Types

This section is empty.

Jump to

Keyboard shortcuts

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