Documentation ¶
Index ¶
- Constants
- func ColorLog(format string, a ...interface{})
- func ColorLogS(format string, a ...interface{}) string
- func CurrentUsername() string
- func ExecCmd(cmdName string, args ...string) (string, string, error)
- func ExecCmdBytes(cmdName string, args ...string) ([]byte, []byte, error)
- func ExecCmdDir(dir, cmdName string, args ...string) (string, string, error)
- func ExecCmdDirBytes(dir, cmdName string, args ...string) ([]byte, []byte, error)
- func HexStr2int(hexStr string) (int, error)
- func Int2HexStr(num int) (hex string)
- func IntContains(arr []int, str int) bool
- func IsDir(dir string) bool
- func IsExist(path string) bool
- func IsFile(path string) bool
- func IsJSON(str string) bool
- func NewTicker(delay, repeat time.Duration) *time.Ticker
- func PowInt(x int, y int) int
- func StringContains(arr []string, str string) bool
- func ToSnakeCase(str string) string
- func ToStr(value interface{}, args ...int) (s string)
- type StrTo
- func (f StrTo) Exist() bool
- func (f StrTo) Float64() (float64, error)
- func (f StrTo) Int() (int, error)
- func (f StrTo) Int64() (int64, error)
- func (f StrTo) MustFloat64() float64
- func (f StrTo) MustInt() int
- func (f StrTo) MustInt64() int64
- func (f StrTo) MustUint8() uint8
- func (f StrTo) String() string
- func (f StrTo) Uint8() (uint8, error)
Constants ¶
const ( Gray = uint8(iota + 90) Red Green Yellow Blue Magenta //NRed = uint8(31) // Normal EndColor = "\033[0m" )
Color number constants.
Variables ¶
This section is empty.
Functions ¶
func ColorLog ¶
func ColorLog(format string, a ...interface{})
ColorLog prints colored log to stdout. See color rules in function 'ColorLogS'.
func ColorLogS ¶
ColorLogS colors log and return colored content. Log format: <level> <content [highlight][path]> [ error ]. Level: TRAC -> blue; ERRO -> red; WARN -> Magenta; SUCC -> green; others -> default. Content: default; path: yellow; error -> red. Level has to be surrounded by "[" and "]". Highlights have to be surrounded by "# " and " #"(space), "#" will be deleted. Paths have to be surrounded by "( " and " )"(space). Errors have to be surrounded by "[ " and " ]"(space). Note: it hasn't support windows yet, contribute is welcome.
func CurrentUsername ¶
func CurrentUsername() string
CurrentUsername returns the username of the current user.
func ExecCmd ¶
ExecCmd executes system command and return stdout, stderr in string type, along with possible error.
func ExecCmdBytes ¶
ExecCmdBytes executes system command and return stdout, stderr in bytes type, along with possible error.
func ExecCmdDir ¶
ExecCmdDir executes system command in given directory and return stdout, stderr in string type, along with possible error.
func ExecCmdDirBytes ¶
ExecCmdDirBytes executes system command in given directory and return stdout, stderr in bytes type, along with possible error.
func HexStr2int ¶
HexStr2int converts hex format string to decimal number.
func Int2HexStr ¶
Int2HexStr converts decimal number to hex format string.
func IntContains ¶
func IsDir ¶
IsDir returns true if given path is a directory, and returns false when it's a file or does not exist.
func StringContains ¶
func ToSnakeCase ¶
ToSnakeCase can convert all upper case characters in a string to underscore format.
Some samples.
"FirstName" => "first_name" "HTTPServer" => "http_server" "NoHTTPS" => "no_https" "GO_PATH" => "go_path" "GO PATH" => "go_path" // space is converted to underscore. "GO-PATH" => "go_path" // hyphen is converted to underscore.