util

package
v0.0.0-...-d9a9959 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2017 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Epoch = time.Date(1970, time.January, 1, 0, 0, 0, 0, time.UTC)

Epoch is the unix epoch time: Jan 1, 1970

Functions

func Getenv

func Getenv(key, fallback string) string

func GetenvInt

func GetenvInt(key string, fallback int) int

func GracefulShutdown

func GracefulShutdown(cleanupFun func()) chan bool

func Hash32

func Hash32(s string) string

func LoadJson

func LoadJson(t testingT, filename string) string

func PanicOnError

func PanicOnError(msg string, err error)

func ReadFileEnvsubst

func ReadFileEnvsubst(path string) string

Read a file (e.g. a configuration file) and replace any environment variable placeholders with their environment counterparts. This is similar to the bash command envsubst

For example, if the file contains: {"key":"$VAR"} then $VAR will be replaced with the environment variable VAR. Only supports environment variables with uppercaser characters and underscore.

func TimeEndOf

func TimeEndOf(t time.Time, granularity string) time.Time

TimeEndOf truncates a time to the end of a granularity, similar to TimeStartOf

func TimeStartOf

func TimeStartOf(t time.Time, granularity string) time.Time

TimeStartOf truncates the given timestamp to the given granularity. This is is similar to Time.Truncate, but is also works for year, month and day.

func ValidateWithTimeout

func ValidateWithTimeout(t testingT, validator func() bool, timeout time.Duration)

Types

This section is empty.

Jump to

Keyboard shortcuts

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