utils

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64Decode added in v0.3.2

func Base64Decode(encodedString string) (string, error)

func Base64DecodeFast added in v0.3.2

func Base64DecodeFast(s string) string

func Base64Encode added in v0.3.2

func Base64Encode[T []byte | string](s T) (string, error)

func ConvertFloat64toTimeInHoursMin

func ConvertFloat64toTimeInHoursMin(f float64) float32

func ConvertJSONToGoType

func ConvertJSONToGoType(res json.RawMessage, customType interface{})

func ConvertMapToAny

func ConvertMapToAny(req interface{}, wres interface{}) (err error)

map[string]interface{}

func ConvertNumericIntoString

func ConvertNumericIntoString[constraint int | int64 | float64](number interface{}) string

ConvertNumericIntoString ... convert numeric(integer,float) into string.

func ConvertStringIntoBool

func ConvertStringIntoBool(data string) bool

func ConvertStringIntoFloat

func ConvertStringIntoFloat(numeric string) float64

ConvertStringIntoFloat ... to convert string into float.

func ConvertStringIntoInt

func ConvertStringIntoInt(numeric string) int

ConvertStringIntoInt ... convert string into integer.

func CreateContext

func CreateContext() (ctx context.Context, cancel context.CancelFunc)

func Debug

func Debug(format string, a ...interface{})

Debug prints a debug information to the log with file and line.

func Deserialize

func Deserialize(byt []byte, obj interface{}) (err error)

Deserialize deserialices the passed []byte into a the passed ptr interface{}

func Function

func Function(skips ...int) string

Function getting the function name of the previous caller

func FunctionName

func FunctionName(skips ...int) string

0 - the same function 1- the calling function ...

func GetBytes

func GetBytes(req interface{}) ([]byte, error)

func GetFunctionName

func GetFunctionName(temp interface{}) string

func GetFunctionNameOnly

func GetFunctionNameOnly(i interface{}) string

func ReadResonse

func ReadResonse(resp *http.Response) (res json.RawMessage, err error)

func Request

func Request(url url.URL, req interface{}, methods ...Method) (res *http.Response, body string, err error)

func RequestWithTimeout

func RequestWithTimeout(url url.URL, req interface{}, timeout time.Duration, methods ...Method) (res *http.Response, body string, err error)

func Serialize

func Serialize(value interface{}) ([]byte, error)

Serialize returns a []byte representing the passed value

Types

type Method

type Method string
const (
	GET    Method = "GET"
	POST   Method = "POST"
	PUT    Method = "PUT"
	PATCH  Method = "PATCH"
	DELETE Method = "DELETE"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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