utilx

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayContainsString

func ArrayContainsString(s *[]string, str string) bool

ArrayContainsString - check if an array of string contains a given string.

func FetchEnvVar

func FetchEnvVar(envName string) string

FetchEnvVar - fetch env var as string.

func FetchEnvVarAsInt16

func FetchEnvVarAsInt16(envName string) int16

FetchEnvVarAsInt16 - fetch env var as int16.

func FetchEnvVarAsInt64

func FetchEnvVarAsInt64(envName string) int64

FetchEnvVarAsInt64 - fetch env var as int64.

func FetchEnvVarAsTime

func FetchEnvVarAsTime(envName string, layout string) time.Time

FetchEnvVarAsTime - fetch evn var as time.

func GenerateUUID

func GenerateUUID() uuid.UUID

GenerateUUID - generate a UUID.

func GzipCompressJSON

func GzipCompressJSON(ctx context.Context, jsonData []byte) ([]byte, error)

GzipCompressJSON compresses a JSON-encoded byte slice using gzip.

func GzipDecompressIfNeeded

func GzipDecompressIfNeeded(ctx context.Context, data []byte) ([]byte, error)

GzipDecompressIfNeeded decompresses the data if it's gzipped

func ParseJSON

func ParseJSON(jsonData []byte) (map[string]interface{}, error)

ParseJSON parses the JSON data into a map

func ParseJSONIntoStruct

func ParseJSONIntoStruct[T json.Unmarshaler](jsonData []byte, target T) (T, error)

ParseJSONIntoStruct parses the JSON data into a map target needs to be a pointer to a struct

func ParseTimeWithMultipleLayouts

func ParseTimeWithMultipleLayouts(s string, layouts ...string) (time.Time, error)

ParseTimeWithMultipleLayouts parses the time string with the provided layouts or as a numeric timestamp.

func RandomString

func RandomString(n int) (string, error)

RandomString - Generate a random string of a given length.

Types

This section is empty.

Jump to

Keyboard shortcuts

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