internalenv

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagAnnotation        = "___leodido_structcli_flagenvs"
	FlagEnvOnlyAnnotation = "___leodido_structcli_flagenvonly"
)

Variables

View Source
var (
	EnvSep = "_"
)

Functions

func BindEnv

func BindEnv(c *cobra.Command) error

func GetPrefix added in v0.10.0

func GetPrefix() string

func IsEnvOnly added in v0.16.0

func IsEnvOnly(f reflect.StructField) bool

IsEnvOnly returns true if the struct field's flagenv tag is set to "only".

func IsValidFlagEnvTag added in v0.16.0

func IsValidFlagEnvTag(tagValue string) bool

IsValidFlagEnvTag validates the flagenv tag value. Returns nil for valid values ("", "true", "false", "only") and an error otherwise.

func NormEnv

func NormEnv(str string) string

func SetPrefix added in v0.10.0

func SetPrefix(v string)

Types

type EnvMode added in v0.16.0

type EnvMode int

EnvMode describes how a field participates in environment variable binding.

const (
	// EnvOff means no env binding for this field.
	EnvOff EnvMode = iota
	// EnvOn means the field has both a CLI flag and env binding.
	EnvOn
	// EnvOnly means the field is settable only via env var (and config), not CLI.
	EnvOnly
)

func GetEnv

func GetEnv(f reflect.StructField, inherit bool, path, alias, envPrefix string) ([]string, EnvMode)

Jump to

Keyboard shortcuts

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