Documentation ¶
Overview ¶
package helpers implements helper functions, such as execute command without shell ENV COLUMNS=80 limit, parse size in bytes or from string etc.
Index ¶
- Constants
- func ExecCommand(cmdString string, timeoutInSeconds int) (out []byte, err error)
- func ExecCommandQuitAfterTimeout(cmdString string, timeoutInSeconds int) (out []byte, err error)
- func Format4HumanSize(size float64) (result string)
- func ParseSize(size string) (sizeBytes float64, err error)
- func StringInSlice(a string, list []string) bool
Constants ¶
View Source
const ( B = 1 KB = 1024 * B MB = 1024 * KB GB = 1024 * MB TB = 1024 * GB )
Variables ¶
This section is empty.
Functions ¶
func ExecCommand ¶
ExecCommand runs shell command with timeout and without ENV COLUMNS=80 limit.
func ExecCommandQuitAfterTimeout ¶
ExecCommandExitAfterTimeout runs shell command exit main process if timeout. NOTICE: context.WithTimeout doesn't works as expected, if cmdString contains pipe command `df -h |grep /dev` and get NAS failed may be dead-wait.
func Format4HumanSize ¶
Format4HumanSize converts bytes from float64 into human-read size in string.
func StringInSlice ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.