envutil

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: MIT Imports: 9 Imported by: 32

Documentation

Index

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 Environ added in v0.3.13

func Environ() map[string]string

Environ like os.Environ, but will returns key-value map[string]string data.

func GetBool added in v0.5.2

func GetBool(name string, def ...bool) bool

GetBool get bool ENV value by key name, can with default value

func GetInt added in v0.5.2

func GetInt(name string, def ...int) int

GetInt get int ENV value by key name, can with default value

func Getenv added in v0.1.7

func Getenv(name string, def ...string) string

Getenv get ENV value by key name, can with default value

func HasShellEnv

func HasShellEnv(shell string) bool

HasShellEnv has shell env check. Usage:

HasShellEnv("sh")
HasShellEnv("bash")

func IsConsole

func IsConsole(out io.Writer) bool

IsConsole check out is console env. alias of the sysutil.IsConsole()

func IsLinux

func IsLinux() bool

IsLinux system

func IsMSys

func IsMSys() bool

IsMSys msys(MINGW64) env. alias of the sysutil.IsMSys()

func IsMac

func IsMac() bool

IsMac system

func IsSupport256Color

func IsSupport256Color() bool

IsSupport256Color render

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

func IsTerminal(fd uintptr) bool

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 IsWin

func IsWin() bool

IsWin system. linux windows darwin

func IsWindows added in v0.3.10

func IsWindows() bool

IsWindows system. alias of IsWin

func ParseEnvValue added in v0.1.7

func ParseEnvValue(str string) string

ParseEnvValue alias of the ParseValue

func ParseValue added in v0.5.2

func ParseValue(val string) (newVal string)

ParseValue parse ENV var value from input string, support default value. vars like ${var}, ${var| default}

Usage:

envutil.ParseValue()

func StdIsTerminal added in v0.3.11

func StdIsTerminal() bool

StdIsTerminal os.Stdout is terminal

func VarParse added in v0.3.11

func VarParse(str string) string

VarParse alias of the ParseValue

func VarReplace added in v0.3.11

func VarReplace(s string) string

VarReplace replaces ${var} or $var in the string according to the values. is alias of the os.ExpandEnv()

Types

This section is empty.

Jump to

Keyboard shortcuts

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