Documentation
¶
Overview ¶
Package envutil provide some commonly ENV util functions.
Index ¶
- Variables
- func EnvPaths() []string
- func Environ() map[string]string
- func GetBool(name string, def ...bool) bool
- func GetInt(name string, def ...int) int
- 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 ParseValue(val string) (newVal string)
- func SearchEnv(keywords string, matchValue bool) map[string]string
- func SearchEnvKeys(keywords string) map[string]string
- func SetEnvs(mp map[string]string)
- func StdIsTerminal() bool
- func VarParse(val string) string
- func VarReplace(s string) string
Constants ¶
This section is empty.
Variables ¶
View Source
var ValueGetter = os.Getenv
ValueGetter Env value provider func.
TIPS: you can custom provide data.
Functions ¶
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 ¶
func IsSupportTrueColor() bool
IsSupportTrueColor render. IsSupportRGBColor
func IsWSL ¶
func IsWSL() bool
IsWSL system env https://github.com/Microsoft/WSL/issues/423#issuecomment-221627364
func ParseValue ¶
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 ¶
SearchEnvKeys values by given keywords
func VarReplace ¶
VarReplace replaces ${var} or $var in the string according to the values.
is alias of the os.ExpandEnv()
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.