Help us shape the future of Go! Take the 2026 Go Developer Survey

envutil

package
v1.21.20 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiscoverProviders

func DiscoverProviders(prefix, suffix string) []string

DiscoverProviders scans environment variables to find configured providers. It looks for environment variables matching the pattern: <prefix><PROVIDER_ID><suffix> For example, with prefix="SAML_PROVIDERS_" and suffix="_ENABLED", it will find "ENTRA_TMIDEV_SAML" from "SAML_PROVIDERS_ENTRA_TMIDEV_SAML_ENABLED=true" SEM@33c446dc529c7bbdd5753f7eb5d6fb76e8f6ae6c: scan environment variables to find provider IDs matching a prefix/suffix pattern (pure)

func Get

func Get(key, fallback string) string

Get retrieves an environment variable with a fallback value. Returns the environment variable value if set and non-empty, otherwise returns the fallback. SEM@f7c112539bdb78e960d4a182be763184e41c531c: fetch an environment variable value with a fallback default (pure)

func ProviderIDToKey

func ProviderIDToKey(providerID string) string

ProviderIDToKey converts an environment variable provider ID to a provider key. It converts to lowercase and replaces underscores with hyphens. For example: "ENTRA_TMIDEV_SAML" -> "entra-tmidev-saml" SEM@33c446dc529c7bbdd5753f7eb5d6fb76e8f6ae6c: convert an uppercase env-var provider ID to a lowercase hyphenated key (pure)

func ScanPrefixedMap

func ScanPrefixedMap(prefix string) map[string]string

ScanPrefixedMap returns a map of every environment variable whose name starts with prefix, keyed by the lowercased remainder of the name and valued by the variable's value. For example, with prefix "OAUTH_PROVIDERS_GOOGLE_USERINFO_CLAIMS_":

OAUTH_PROVIDERS_GOOGLE_USERINFO_CLAIMS_SUBJECT_CLAIM=sub  -> {"subject_claim": "sub"}
OAUTH_PROVIDERS_GOOGLE_USERINFO_CLAIMS_EMAIL_CLAIM=email  -> {"email_claim": "email"}

Returns a non-nil empty map when nothing matches. Used for OAuth userinfo claim mappings and additional OAuth parameters, which are dynamic-cardinality (the concrete keys are only known at runtime). SEM@f622b659f3a1f536265633cbf9dc2ff0ec703170: scan environment variables under a prefix into a lowercase suffix-to-value map (reads env)

Types

This section is empty.

Jump to

Keyboard shortcuts

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