utils

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2023 License: Apache-2.0 Imports: 7 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 added in v0.6.3

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 added in v0.6.3

func IsInteger(val float64) bool

func MapToSlice added in v0.7.0

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 added in v0.5.3

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 added in v0.6.2

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