comfunc

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: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentShell added in v0.5.3

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.5.3

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.5.3

func ExpandPath(pathStr string) string

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

func HasShellEnv added in v0.5.3

func HasShellEnv(shell string) bool

HasShellEnv has shell env check.

Usage:

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

func ShellExec added in v0.5.3

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

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

func TryStructToMap

func TryStructToMap(st interface{}) (map[string]interface{}, error)

TryStructToMap simple convert structs to map by reflect

Types

This section is empty.

Jump to

Keyboard shortcuts

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