utils

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(haystack []string, needle string) bool

Contains returns true if the given string array (haystack) contains given string (needle)

func FormatThumbnailURL

func FormatThumbnailURL(baseURL string, r *http.Request, urlString string) string

func HasBits added in v1.2.1

func HasBits(sum int32, bit int32) bool

HasBits checks if sum contains bit by performing a bitwise AND operation between values

func IsDomain

func IsDomain(url *url.URL, domain string) bool

IsDomain checks whether `url`s domain matches the given domain exactly (non-case sensitive) The `domain` string must be fully lowercased

func IsDomains

func IsDomains(url *url.URL, domains map[string]struct{}) bool

IsDomains checks whether `url`s domain matches any of the given domains exactly (non-case sensitive) The `domains` map should only contain fully lowercased domains

func IsSubdomainOf

func IsSubdomainOf(url *url.URL, parent string) bool

IsSubdomainOf checks whether `url` is a subdomain of `parent`

func MarshalNoDur

func MarshalNoDur(i interface{}) ([]byte, time.Duration, error)

func SetFromSlice added in v1.2.2

func SetFromSlice(slice []interface{}) map[interface{}]struct{}

SetFromSlice takes a slice and returns a set (represented as a map of struct{}s)

func StringPtr

func StringPtr(s string) *string

func TruncateString

func TruncateString(s string, maxLength int) string

TruncateString truncates string down to the maximum length with a unicode triple dot if truncation took place

func UnescapeURLArgument

func UnescapeURLArgument(r *http.Request, key string) (string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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