utils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSONDecode

func JSONDecode(content []byte, destinations ...interface{}) (interface{}, error)

JSONDecode decode given json byte slice to corresponding struct.

func JSONEncode

func JSONEncode(source interface{}, unescape bool) ([]byte, error)

JSONEncode encode given interface to json byte slice.

func JSONFormatToReadable

func JSONFormatToReadable(source []byte) ([]byte, error)

JSONFormatToReadable formats given json byte slice prettily.

func StringToTime

func StringToTime(timeString, format string) (time.Time, error)

StringToTime transforms given string to time.

func StringToUnixInt

func StringToUnixInt(timeString, format string) int

StringToUnixInt transforms given string to unix time int.

func TimeToString

func TimeToString(timeValue time.Time, format string) string

TimeToString transforms given time to string.

func WaitFor

func WaitFor(f func() bool) error

WaitFor wait a function return true.

func WaitForSpecific

func WaitForSpecific(f func() bool, timeout time.Duration, waitInterval time.Duration) error

WaitForSpecific wait a function return true.

func WaitForSpecificOrError

func WaitForSpecificOrError(f func() (bool, error), timeout time.Duration, waitInterval time.Duration) error

WaitForSpecificOrError wait a function return true or error.

func YAMLDecode

func YAMLDecode(content []byte, destinations ...interface{}) (interface{}, error)

YAMLDecode decode given yaml byte slice to corresponding struct.

func YAMLEncode

func YAMLEncode(source interface{}) ([]byte, error)

YAMLEncode encode given interface to yaml byte slice.

Types

type TimeoutError

type TimeoutError struct {
	// contains filtered or unexported fields
}

TimeoutError An Error represents a timeout error.

func NewTimeoutError

func NewTimeoutError(timeout time.Duration) *TimeoutError

NewTimeoutError create a new TimeoutError

func (*TimeoutError) Error

func (e *TimeoutError) Error() string

Error message

func (*TimeoutError) Timeout

func (e *TimeoutError) Timeout() time.Duration

Timeout duration

Jump to

Keyboard shortcuts

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