helpers

package
v0.0.0-...-d6d71be Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2018 License: MIT Imports: 9 Imported by: 4

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

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

func ExecCommand(cmdString string, timeoutInSeconds int) (out []byte, err error)

ExecCommand runs shell command with timeout and without ENV COLUMNS=80 limit.

func ExecCommandQuitAfterTimeout

func ExecCommandQuitAfterTimeout(cmdString string, timeoutInSeconds int) (out []byte, err error)

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

func Format4HumanSize(size float64) (result string)

Format4HumanSize converts bytes from float64 into human-read size in string.

func ParseSize

func ParseSize(size string) (sizeBytes float64, err error)

ParseSize converts human-read size from string into bytes in float64.

func StringInSlice

func StringInSlice(a string, list []string) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

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