envutil

package
v0.17.10 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 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 GetConfigDir

func GetConfigDir() (string, error)

GetConfigDir returns the sprout configuration directory path.

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 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