utils

package
v0.0.0-...-e93c85d Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTPGet    string = "GET"
	HTTPPost   string = "POST"
	HTTPDelete string = "DELETE"
	HTTPPut    string = "PUT"
)

Variables

This section is empty.

Functions

func ContainsStrSli

func ContainsStrSli(A []string, a string) bool

ContainsStrSli returns true if the a exists in the slice A.

func GetCallerInfo

func GetCallerInfo(level int) (caller string, fileName string, lineNum int)

GetCallerInfo returns the name of method caller and file name. It also returns the line number.

func Http

func Http(method, url, username, password string, data []byte) (*http.Response, error)

func HttpDelete

func HttpDelete(url, username, password string, data []byte) (*http.Response, error)

func HttpGet

func HttpGet(url, username, password string) (*http.Response, error)

func HttpPost

func HttpPost(url, username, password string, data []byte) (*http.Response, error)

func PanicHandler

func PanicHandler() (caller string, fileName string, lineNum int, stackTrace string, rec interface{})

PanicHandler catches a panic and logs an error. Suppose to be called via defer.

func Retry

func Retry(interval time.Duration, round int, retry func() (bool, error)) (bool, error)

Retry will retry the given condition function with specific time interval and retry round. It will return true if the condition is met. If it is timeout, it will return false. Otherwise, it will return the error encountered in the retry round.

Types

This section is empty.

Jump to

Keyboard shortcuts

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