utils

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DegToRad is a constant to convert degrees to radians
	DegToRad = 0.017453292519943295769236907684886127134428718885417 // N[Pi/180, 50]
	// RadToDeg is a constant to convert radians to degrees
	RadToDeg = 57.295779513082320876798154814105170332405472466564 // N[180/Pi, 50]
)

Variables

This section is empty.

Functions

func Add

func Add(x, y int) int

Add does a simple addition

func ConcatURL

func ConcatURL(url, path string) string

ConcatURL concatenate the url and path

func ElapsedSec

func ElapsedSec(lastTimestamp int64, elapsedTime int64) bool

ElapsedSec returns true if lastTimestamp + elapsed time is in the past

func FormattedDateUTC

func FormattedDateUTC(t time.Time) string

FormattedDateUTC returns the date formatted as RFC1123

func FuzzyTimeStr

func FuzzyTimeStr(duration time.Duration) string

FuzzyTimeStr returns the duration as fuzzy time

func GetDistanceKm

func GetDistanceKm(lat1, lon1, lat2, lon2 float32) float32

GetDistanceKm returns the distance in km between two coordinates

func Hostname

func Hostname() string

Hostname return the host name as a string

func IsAdditionalCountry

func IsAdditionalCountry(clientInfo network.GeoIPRecord, list []string) bool

IsAdditionalCountry returns true if the clientInfo country is in list

func IsInSlice

func IsInSlice(a string, list []string) bool

IsInSlice returns true is `a` is contained in `list` Warning: this is slow, don't use it for long datasets

func IsPrimaryCountry

func IsPrimaryCountry(clientInfo network.GeoIPRecord, list []string) bool

IsPrimaryCountry returns true if the clientInfo country is the primary country

func IsStopped

func IsStopped(stop <-chan struct{}) bool

IsStopped returns true if a stop has been requested

func Max

func Max(v1, v2 int) int

Max returns the highest of the two values

func Min

func Min(v1, v2 int) int

Min returns the smallest of the two values

func NormalizeURL

func NormalizeURL(url string) string

NormalizeURL adds a trailing slash to the URL

func Plural

func Plural(value interface{}) string

Plural returns a single 's' if there are more than one value

func ReadableSize

func ReadableSize(value int64) string

ReadableSize returns a file size in a human readable form

func SanitizeLocationCodes

func SanitizeLocationCodes(input string) string

SanitizeLocationCodes sanitizes the given location codes

func TimeKeyCoverage

func TimeKeyCoverage(start, end time.Time) (dates []string)

TimeKeyCoverage returns a slice of strings covering the date range used in the redis backend.

func Version

func Version() string

Version returns the version as a string

Types

This section is empty.

Jump to

Keyboard shortcuts

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