Documentation
¶
Overview ¶
Package envutil provide some commonly ENV util functions.
Index ¶
- Variables
- func EnvMap() map[string]string
- func EnvPaths() []string
- func Environ() map[string]string
- func GetBool(name string, def ...bool) bool
- func GetInt(name string, def ...int) int
- func GetMulti(names ...string) map[string]string
- func Getenv(name string, def ...string) string
- func HasShellEnv(shell string) bool
- func IsConsole(out io.Writer) bool
- func IsGithubActions() bool
- func IsLinux() bool
- func IsMSys() bool
- func IsMac() bool
- func IsSupport256Color() bool
- func IsSupportColor() bool
- func IsSupportTrueColor() bool
- func IsTerminal(fd uintptr) bool
- func IsWSL() bool
- func IsWin() bool
- func IsWindows() bool
- func ParseEnvValue(val string) string
- func ParseOrErr(val string) (string, error)
- func ParseValue(val string) string
- func SearchEnv(keywords string, matchValue bool) map[string]string
- func SearchEnvKeys(keywords string) map[string]string
- func SetEnvMap(mp map[string]string)
- func SetEnvs(kvPairs ...string)
- func StdIsTerminal() bool
- func UnsetEnvs(keys ...string)
- func VarParse(val string) string
- func VarReplace(s string) string
Constants ¶
This section is empty.
Variables ¶
var ValueGetter = os.Getenv
ValueGetter Env value provider func.
TIPS: you can custom provide data.
Functions ¶
func EnvMap ¶ added in v0.6.7
EnvMap like os.Environ, but will returns key-value map[string]string data.
func Environ ¶ added in v0.3.13
Environ like os.Environ, but will returns key-value map[string]string data.
func IsSupportColor ¶
func IsSupportColor() bool
IsSupportColor check current console is support color.
Supported:
linux, mac, or windows's ConEmu, Cmder, putty, git-bash.exe
Not support:
windows cmd.exe, powerShell.exe
func IsSupportTrueColor ¶ added in v0.2.5
func IsSupportTrueColor() bool
IsSupportTrueColor render. IsSupportRGBColor
func IsTerminal ¶ added in v0.3.10
IsTerminal isatty check
Usage:
envutil.IsTerminal(os.Stdout.Fd())
func IsWSL ¶ added in v0.3.10
func IsWSL() bool
IsWSL system env https://github.com/Microsoft/WSL/issues/423#issuecomment-221627364
func ParseEnvValue ¶ added in v0.1.7
ParseEnvValue alias of the ParseValue
func ParseOrErr ¶ added in v0.6.13
ParseOrErr parse ENV var value from input string, support default value.
Diff with the ParseValue, this support return error.
With error format: ${VAR_NAME | ?error}
func ParseValue ¶ added in v0.5.2
ParseValue parse ENV var value from input string, support default value.
Format:
${var_name} Only var name ${var_name | default} With default value
Usage:
envutil.ParseValue("${ APP_NAME }") envutil.ParseValue("${ APP_ENV | dev }")
func SearchEnvKeys ¶ added in v0.6.2
SearchEnvKeys values by given keywords
func SetEnvs ¶ added in v0.6.0
func SetEnvs(kvPairs ...string)
SetEnvs set multi k-v ENV pairs to os
func VarReplace ¶ added in v0.3.11
VarReplace replaces ${var} or $var in the string according to the values.
is alias of the os.ExpandEnv()
Types ¶
This section is empty.