utils

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsString

func ContainsString(arr []string, v string) bool

func GetReadableDuration

func GetReadableDuration(durationStr string) (string, error)

GetReadableDuration returns a human-readable duration string in integer days preferably, or the original string if it's either not a valid duration or a days value is not integer.

func IsInteger

func IsInteger(val float64) bool

func IsValidUUID

func IsValidUUID(u string) bool

IsValidUUID returns true if uuid is valid

func MapToSlice

func MapToSlice(m map[string]string) []string

MapToSlice converts map[string]string to []string

Example:

Input: map[string]string{ "key1": "value1", "key2": "value2", "key3": "value3"}
Output: []string{"key1=value1", "key2=value2", "key3=value3"}

func ReturnJSON

func ReturnJSON(w http.ResponseWriter, data interface{})

ReturnJSON writes JSON to the response body

func SubsliceExists

func SubsliceExists(slice, subslice []string) (bool, int)

func ValidateStruct

func ValidateStruct(v interface{}) error

ValidateStruct validates the struct and returns error if there is any invalid values

Types

type AnyTime

type AnyTime struct{}

AnyTime is used to expect arbitrary time value

func (AnyTime) Match

func (a AnyTime) Match(v driver.Value) bool

Match satisfies sqlmock.Argument interface

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

Jump to

Keyboard shortcuts

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