sysutil

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2021 License: MIT Imports: 11 Imported by: 31

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentShell added in v0.1.4

func CurrentShell(onlyName bool) (path string)

CurrentShell get current used shell env file. eg "/bin/zsh" "/bin/bash". if onlyName=true, will return "zsh", "bash"

func ExecCmd added in v0.1.4

func ExecCmd(binName string, args []string, workDir ...string) (string, error)

ExecCmd an command and return output. Usage:

ExecCmd("ls", []string{"-al"})

func ExpandPath added in v0.3.9

func ExpandPath(path string) string

ExpandPath will parse `~` as user home dir path.

func FindExecutable added in v0.3.8

func FindExecutable(binName string) (string, error)

FindExecutable in the system

Usage:

FindExecutable("bash")

func HasExecutable added in v0.3.8

func HasExecutable(binName string) bool

HasExecutable in the system

Usage:

HasExecutable("bash")

func HasShellEnv added in v0.1.4

func HasShellEnv(shell string) bool

HasShellEnv has shell env check.

Usage:

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

func HomeDir added in v0.3.9

func HomeDir() string

HomeDir get user home dir path.

func IsConsole added in v0.2.2

func IsConsole(out io.Writer) bool

IsConsole check out is in stderr/stdout/stdin

Usage:

sysutil.IsConsole(os.Stdout)

func IsLinux added in v0.2.2

func IsLinux() bool

IsLinux system

func IsMSys added in v0.2.2

func IsMSys() bool

IsMSys msys(MINGW64) env,不一定支持颜色

func IsMac added in v0.2.2

func IsMac() bool

IsMac system

func IsTerminal added in v0.3.9

func IsTerminal(fd uintptr) bool

IsTerminal isatty check

Usage: sysutil.IsTerminal(os.Stdout.Fd())

func IsWin added in v0.2.2

func IsWin() bool

IsWin system. linux windows darwin

func IsWindows added in v0.2.3

func IsWindows() bool

IsWindows system. linux windows darwin

func Kill

func Kill(pid int, signal syscall.Signal) error

Kill process by pid

func ProcessExists

func ProcessExists(pid int) bool

ProcessExists check process exists by pid

func QuickExec added in v0.1.4

func QuickExec(cmdLine string, workDir ...string) (string, error)

QuickExec quick exec an simple command line Usage:

QuickExec("git status")

func ShellExec added in v0.1.4

func ShellExec(cmdStr string, shells ...string) (string, error)

ShellExec exec command by shell cmdStr eg. "ls -al"

func StdIsTerminal added in v0.3.11

func StdIsTerminal() bool

StdIsTerminal os.Stdout is terminal

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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