utils

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AskForInput

func AskForInput(prompt string, defaultVal string, isPassword bool) string
 askForInput promts the user to provide a value via StdIn
	if isPassword=true, no local echo to the console is provided
	if isPassword=false and the provided input is empty, the default value is returned instead

func GetEpoch

func GetEpoch(t time.Time) float64

GetEpoch returns an Epoch timestamp with millisecond precision starting from time t

func GetEpochNow

func GetEpochNow() float64

GetEpochNow returns an the current time as Epoch, expressed in seconds with a decimal part

func IsReachable

func IsReachable(target url.URL) error

IsReachable tries to connect to the target URL and returns an error if this is not possible

func NewErrInvalidParam added in v1.7.0

func NewErrInvalidParam(context string, err error, msg string, a ...interface{}) error

func NewHTTPClient

func NewHTTPClient(timeout time.Duration, insecureSkipVerify bool, proxy string, tlsCAcerts, tlsClientCert, tlsClientKey string) (*http.Client, error)

NewHTTPClient configures a new HTTP client which can be used to issue requests to external services

func NewHTTPTransport added in v1.6.0

func NewHTTPTransport(timeout time.Duration, retries int, backoff time.Duration, proxy string, insecureSkipVerify bool, tlsCAcerts, tlsClientCert, tlsClientKey string) (http.RoundTripper, error)

NewHTTPCNewHTTPTransport configures a new HTTP transport with the provided settings. The transport can be used to instantiate a http client

Types

type ErrInvalidParam added in v1.7.0

type ErrInvalidParam struct {
	Context string // function where error happened
	Msg     string // details message
	Err     error  // wrapped error
}

func (*ErrInvalidParam) Error added in v1.7.0

func (e *ErrInvalidParam) Error() string

func (*ErrInvalidParam) Unwrap added in v1.7.0

func (e *ErrInvalidParam) Unwrap() error

Unwrap https://github.com/golang/go/blob/release-branch.go1.17/src/errors/wrap.go

Jump to

Keyboard shortcuts

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