tools

package
v0.0.0-...-70a4357 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

This package contains the tools that frequently used by other packages

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GrpcConnect

func GrpcConnect(addr string, tlsEnabled bool) (*grpc.ClientConn, error)

func HttpGetReqPersist

func HttpGetReqPersist(url string, opts ...ReqOption) ([]byte, error)

func HttpPostReqPersist

func HttpPostReqPersist(url string, payload io.Reader, opts ...ReqOption) ([]byte, error)

func NewError

func NewError(code int, text string) error

func NewErrorf

func NewErrorf(code int, format string, a ...interface{}) error

func PrettyPrint

func PrettyPrint(v any, prefix ...string)

useful for debugging

func RandomBool

func RandomBool(chancePercent int) bool

It generates a random boolean status the `chancePercent` should be between 0 and 100

func RandomNumberF

func RandomNumberF(rangeLower float64, rangeUpper float64) float64

This function receives a pair of min and max float64 numbers and generates a random number in that range (inclusive)

func RandomNumberI

func RandomNumberI(rangeLower int64, rangeUpper int64) int64

This function receives a pair of min and max int64 numbers and generates a random number in that range (inclusive)

func RandomString

func RandomString(length int) string

This function receives the length of a string and generates a random string

func UniqueStringSlice

func UniqueStringSlice(input []string) []string

func WaitCountdown

func WaitCountdown(s time.Duration, msg string)

Types

type CodeError

type CodeError struct {
	Code int
	Text string
}

CodeError is a error with a code (like 404 Not Found).

func (CodeError) Error

func (e CodeError) Error() string

type ReqOption

type ReqOption interface {
	// contains filtered or unexported methods
}

func HttpAddHeader

func HttpAddHeader(key, value string) ReqOption

func HttpWithRetry

func HttpWithRetry(r uint) ReqOption

func HttpWithTimeout

func HttpWithTimeout(t time.Duration) ReqOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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