utils

package
v0.11.3-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PermanentDurationLabel = "Permanent"
)

Variables

This section is empty.

Functions

func ContainsString

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

func GetGlobalURN added in v0.8.0

func GetGlobalURN(source, scope, kind, identifier string) string

GetGlobalURN returns a GlobalURN for a given source, scope, kind and identifier format is urn:<source>:<scope>:<kind>:<identifier>

func GetReadableDuration added in v0.7.1

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.7.1

func IsInteger(val float64) bool

func IsValidUUID added in v0.7.3

func IsValidUUID(u string) bool

IsValidUUID returns true if uuid is valid

func MapToSlice added in v0.7.2

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

func StructToMap(v interface{}) (map[string]interface{}, error)

StructToMap converts a struct to a map using json marshalling

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