utils

package
v2.0.0-alpha-4 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 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 In

func In[T comparable](element T, set []T) bool

In checks presence of 'elemet' within slice 'set'

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 IsSubset

func IsSubset[T comparable](subset, set []T) bool

IsSubset returns true if the 'subset' array is completely contained in the 'set' array. There must be at least the same number of duplicate values in 'set' as there are in 'subset'.

func ListOfVals

func ListOfVals[T any, PT any](source []T, accessor func(*T) PT) []PT

ListOfVals accesses a list of composite values 'source' of type T, applies the 'accessor' function to it to extract a value of type PT and retusn a list of the extracted values []PT. Elements of the resulting list are in the same order as found in the 'source' list Limitations: T must be an addressable type

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

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

This section is empty.

Jump to

Keyboard shortcuts

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