Documentation
¶
Overview ¶
this package hosts utilities that probably don't belong elsewhere. a utils package is fine. rule: nothing in this package can depend on any other package in this project.
Index ¶
- func CtxFireLoop(ctx context.Context, delay time.Duration, fn func())
- func CtxFireLoopTicker(ctx context.Context, ticker *time.Ticker, fn func())
- func CtxLoop(ctx context.Context, delay time.Duration, fn func())
- func CtxLoopTicker(ctx context.Context, ticker *time.Ticker, fn func())
- func EnsureDirForFile(file string) error
- func InterfaceSlice(any ...interface{}) []interface{}
- type AtomicBool
- type JsonReader
- type Teardowns
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CtxFireLoop ¶
CtxFireLoop blocks and fires the callback function on a tick. The callback function is fired first before the first delay.
func CtxFireLoopTicker ¶
CtxFireLoopTicker blocks and fires the callback function on a tick. The callback function is fired first before the first delay.
func CtxLoopTicker ¶
CtxLoopTicker blocks and fires the callback function on a tick.
func EnsureDirForFile ¶
EnsureDirForFile ensures that the specified file's parent directory exists.
func InterfaceSlice ¶
func InterfaceSlice(any ...interface{}) []interface{}
Converts args to an interface slice using the following rules:
- Returns empty slice if no args are passed
- For a single argument which is of a slice type, the slice is converted and returned.
- For a single argument which is not a slice type, the value is returned within a single-element slice.
- For multiple arguments, returns a slice with all the args
Types ¶
type AtomicBool ¶
type AtomicBool int32
func (*AtomicBool) IsSet ¶
func (b *AtomicBool) IsSet() bool
func (*AtomicBool) SetFalse ¶
func (b *AtomicBool) SetFalse()
func (*AtomicBool) SetTrue ¶
func (b *AtomicBool) SetTrue()
type JsonReader ¶
type JsonReader struct {
// contains filtered or unexported fields
}
JsonReader is a convenience type that is constructed with a type to be serialized using newJsonReader. it implements io.Reader and writes JSON bytes to the client. Useful for supplying a reader for the body of an http request. This allows the client to omit the extra step of encoding a struct into a byte slice and then passing a bytes.NewReader(b) to something expecting that reader.
func NewJsonReader ¶
func NewJsonReader(val interface{}) *JsonReader