utils

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CombineURLPath

func CombineURLPath(p string, ps ...string) (r string)

CombineURLPath combines multiple parts of a url

func CompareNullableIntsWithNilAsInfinity

func CompareNullableIntsWithNilAsInfinity(a, b *int64) int

CompareNullableIntsWithNilAsInfinity compare two *int64 and handles nil as infinity. It returns 0 if both are equal, a positive value if a is greater than b, a negative value is a is less than b

func GetTimeIn

func GetTimeIn(seconds int64) time.Time

GetTimeIn adds the passed number of seconds to the current time

func IPIsIn

func IPIsIn(ip string, ips []string) bool

IPIsIn checks if a ip is in a slice of ips, it will also check ip subnets

func IPsAreSubSet

func IPsAreSubSet(ipsA, ipsB []string) bool

IPsAreSubSet checks if all ips of ipsA are contained in ipsB, it will also check ip subnets

func IntersectSlices

func IntersectSlices(a, b []string) (res []string)

IntersectSlices returns the common elements of two slices

func IsJWT

func IsJWT(token string) bool

IsJWT checks if a string is a jwt

func IsSubSet

func IsSubSet(a, b []string) bool

IsSubSet checks if all strings of a slice 'a' are contained in the slice 'b'

func MinInt

func MinInt(a int, ints ...int) int

MinInt returns the smallest of the passed integers

func MinInt64

func MinInt64(a int64, ints ...int64) int64

MinInt64 returns the smallest of the passed integers

func NewInt added in v0.2.0

func NewInt(i int) *int

NewInt creates a new *int

func NewInt64

func NewInt64(i int64) *int64

NewInt64 creates a new *int64

func OR added in v0.2.0

func OR(bools ...bool) bool

OR logically ORs multiple bools

func ORErrors

func ORErrors(errs ...error) error

ORErrors returns the first passed error that is not nil

func RSplitN added in v0.3.3

func RSplitN(s, del string, n int) []string

RSplitN splits a string s at the delimiter del into n pieces. Unlike strings.SplitN RSplitN splits the string starting from the right side

func RandASCIIString

func RandASCIIString(n int) string

RandASCIIString returns a random string consisting of ASCII characters of the given length.

func ReplaceStringInSlice added in v0.2.0

func ReplaceStringInSlice(s *[]string, o, n string, caseSensitive bool)

ReplaceStringInSlice replaces all occurrences of a string in a slice with another string

func SliceUnion

func SliceUnion(a ...[]string) []string

SliceUnion will create a slice of string that contains all strings part of the passed slices

func SplitIgnoreEmpty

func SplitIgnoreEmpty(s, del string) (ret []string)

SplitIgnoreEmpty splits a string at the specified delimiter without generating empty parts

func StringInSlice

func StringInSlice(key string, slice []string) bool

StringInSlice checks if a string is in a slice of strings

func StructToStringMap

func StructToStringMap(st interface{}, tag string) map[string]string

StructToStringMap creates a string map from an interface{} using the passed tag name

func StructToStringMapUsingJSONTags

func StructToStringMapUsingJSONTags(st interface{}) map[string]string

StructToStringMapUsingJSONTags creates a string map from an interface{} using json tags

func UniqueSlice

func UniqueSlice(a []string) (unique []string)

UniqueSlice will remove all duplicates from the given slice of strings

Types

This section is empty.

Directories

Path Synopsis
Package fileutil provides utility functions related to files.
Package fileutil provides utility functions related to files.

Jump to

Keyboard shortcuts

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