utils

package
v0.16.7 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2019 License: MIT Imports: 17 Imported by: 3

Documentation

Index

Constants

View Source
const Version = "v0.16.7"

Version version the project

Variables

View Source
var Stderr = ansi.NewAnsiStderr()

Stderr ...

View Source
var Stdout = ansi.NewAnsiStdout()

Stdout ...

Functions

func All

func All(actions ...func())

All run all actions concurrently

func C

func C(str interface{}, color string) string

C color terminal string

func ClearScreen

func ClearScreen() error

ClearScreen ...

func Dump

func Dump(val interface{})

Dump ...

func E

func E(args ...interface{}) []interface{}

E the last arg is error, panic it

func E1

func E1(arg interface{}, err error) interface{}

E1 if the second arg is error panic it, or return the first arg

func Err

func Err(v ...interface{})

Err log to stderr with timestamp and stack trace

func ErrArg

func ErrArg(args ...interface{}) error

ErrArg get the last arg as error

func JSON

func JSON(data interface{}) (res gjson.Result)

JSON parse json for easily access the value from json path

func Log

func Log(v ...interface{})

Log log to stdout with timestamp

func MustToJSON added in v0.16.3

func MustToJSON(data interface{}) string

MustToJSON encode data to json string

func MustToJSONBytes added in v0.16.3

func MustToJSONBytes(data interface{}) []byte

MustToJSONBytes encode data to json bytes

func Noop

func Noop(_ ...interface{})

Noop swallow all args and do nothing

func RandBytes

func RandBytes(len int) []byte

RandBytes generate random bytes with specified byte length

func RandString

func RandString(len int) string

RandString generate random string with specified string length

func S

func S(tpl string, params ...interface{}) string

S Template render, the params is key-value pairs

func Sdump

func Sdump(val interface{}) string

Sdump ...

func Try

func Try(fn func()) (err interface{})

Try try fn with recover, return the panic as value

Types

type Nil

type Nil struct{}

Nil used to create empty channel

Jump to

Keyboard shortcuts

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