Documentation ¶
Index ¶
- Variables
- func BaseTime(t time.Time) time.Time
- func Bearing(lat1, lon1, lat2, lon2 float64) float64
- func CreateIDs(ids []string) string
- func CreateIntIDs(ids []int) string
- func MustDB() *sqlx.DB
- func RedisCache(k string, b []byte) (err error)
- func RedisCacheURL(u string) (b []byte, err error)
- func RedisGet(k string) (b []byte, err error)
- func SecsToTimeStr(secs int) string
- func TimeStrToSecs(timeStr string) int
- func TimeToDepartureSecs(t time.Time) int
Constants ¶
This section is empty.
Variables ¶
var ( // DBConn is our shared connection to postgres DBConn *sqlx.DB )
Functions ¶
func BaseTime ¶
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 Bearing ¶
stolen from https://github.com/kellydunn/golang-geo/blob/master/point.go in turn stolen from http://www.movable-type.co.uk/scripts/latlong.html
func CreateIDs ¶
CreateIDs turns a slice of strings into a single string suitable for substitution into an IN clause.
func CreateIntIDs ¶
CreateIntIDs takes aslice of ints and returns a single sting suitable for substitution into an IN clause
func RedisCache ¶
RedisCache saves bytes to redis using key k.
func RedisCacheURL ¶
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 ¶
RedisGet retrieves the data cached at k or returns an error if there is no cached version or there's another error.
func SecsToTimeStr ¶
SecsToTimeStr takes an integer number of seconds and returns a string like "01:23:45" (hours:minutes:seconds)
func TimeStrToSecs ¶
TimeStrToSecs takes a string like "01:23:45" (hours:minutes:seconds) and returns a integer of the total number of seconds
func TimeToDepartureSecs ¶
TimeToDepartureSecs takes a time value and converts it to the number of seconds since the start of the day
Types ¶
This section is empty.