etc

package
v0.0.0-...-f887610 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DBConn is our shared connection to postgres
	DBConn *sqlx.DB
)

Functions

func BaseTime

func BaseTime(t time.Time) time.Time

BaseTime takes a time and returns the same time with the hour, minute, second and nanosecond values set to zero, so that it represents the start of the day

func CreateIDs

func CreateIDs(ids []string) string

CreateIDs turns a slice of strings into a single string suitable for substitution into an IN clause.

func CreateIntIDs

func CreateIntIDs(ids []int) string

CreateIntIDs takes aslice of ints and returns a single sting suitable for substitution into an IN clause

func MustDB

func MustDB() *sqlx.DB

MustDB returns an *sqlx.DB or panics

func RedisCache

func RedisCache(k string, b []byte) (err error)

RedisCache saves bytes to redis using key k.

func RedisCacheURL

func RedisCacheURL(u string) (b []byte, err error)

RedisCacheURL takes a URL and returns the bytes of the response from running a GET on that URL. Responses are cached for redisTTL seconds. If Redis is not available, an error is logged and we hit the URL directly.

func RedisGet

func RedisGet(k string) (b []byte, err error)

RedisGet retrieves the data cached at k or returns an error if there is no cached version or there's another error.

func SecsToTimeStr

func SecsToTimeStr(secs int) string

SecsToTimeStr takes an integer number of seconds and returns a string like "01:23:45" (hours:minutes:seconds)

func TimeStrToSecs

func TimeStrToSecs(timeStr string) int

TimeStrToSecs takes a string like "01:23:45" (hours:minutes:seconds) and returns a integer of the total number of seconds

func TimeToDepartureSecs

func TimeToDepartureSecs(t time.Time) int

TimeToDepartureSecs takes a time value and converts it to the number of seconds since the start of the day

Types

This section is empty.

Jump to

Keyboard shortcuts

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