envutil

package
v0.2.19 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandEnvArgs added in v0.2.15

func ExpandEnvArgs(args []string) []string

ExpandEnvArgs expands Docker -e flags that reference environment variables. Converts "-e VAR_NAME" to "-e VAR_NAME=value" by reading from the process environment. If the variable is not set, the flag is passed through unchanged.

func GetEnvBool

func GetEnvBool(envKey string, defaultValue bool) bool

GetEnvBool returns the boolean value of the environment variable specified by envKey. If the environment variable is not set or is empty, it returns the defaultValue. Truthy values (case-insensitive): "1", "true", "yes", "on" Falsy values (case-insensitive): "0", "false", "no", "off" Any other value returns the defaultValue.

func GetEnvDuration added in v0.2.13

func GetEnvDuration(envKey string, defaultValue time.Duration) time.Duration

GetEnvDuration returns the time.Duration value of the environment variable specified by envKey. If the environment variable is not set, is empty, or cannot be parsed by time.ParseDuration, it returns the defaultValue. Accepts any string valid for time.ParseDuration (e.g. "2h", "30m", "90s").

func GetEnvInt

func GetEnvInt(envKey string, defaultValue int) int

GetEnvInt returns the integer value of the environment variable specified by envKey. If the environment variable is not set, is empty, cannot be parsed as an integer, or is not positive (> 0), it returns the defaultValue. This function validates that the value is a positive integer.

func GetEnvString

func GetEnvString(envKey, defaultValue string) string

GetEnvString returns the value of the environment variable specified by envKey. If the environment variable is not set or is empty, it returns the defaultValue.

func LookupGitHubAPIURL added in v0.2.18

func LookupGitHubAPIURL(defaultURL string) string

LookupGitHubAPIURL returns the GitHub API base URL from the GITHUB_API_URL environment variable. If the variable is not set or empty, it returns defaultURL. Any trailing slash is stripped from the result.

func LookupGitHubToken added in v0.2.18

func LookupGitHubToken() string

LookupGitHubToken searches environment variables for a GitHub token using a canonical priority order. It returns the first non-empty (trimmed) value found, or an empty string if none is set.

Priority order:

  1. GITHUB_MCP_SERVER_TOKEN
  2. GITHUB_TOKEN
  3. GITHUB_PERSONAL_ACCESS_TOKEN
  4. GH_TOKEN

Types

This section is empty.

Jump to

Keyboard shortcuts

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