utils

package
v0.0.0-...-c797b29 Latest Latest
Warning

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

Go to latest
Published: May 24, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EditMutableContextValue

func EditMutableContextValue[V any](ctx context.Context, key MutableContextKey[V], editor EditorFunc[V])

func ForkMutableContext

func ForkMutableContext(ctx context.Context) context.Context

func MakeRandomStr

func MakeRandomStr(numBytes int) string

func MustGetMutableContextValue

func MustGetMutableContextValue[V any](ctx context.Context, key MutableContextKey[V]) V

func PanicIfErr

func PanicIfErr(err error)

func PanicIfF

func PanicIfF(cond bool, msg string, args ...interface{})

func SetMutableContextValue

func SetMutableContextValue[V any](ctx context.Context, key MutableContextKey[V], value V)

func StaticClock

func StaticClock(sec int64) func() time.Time

func TryGetMutableContextValue

func TryGetMutableContextValue[V any](ctx context.Context, key MutableContextKey[V]) (V, bool)

Types

type AbsoluteTimeSec

type AbsoluteTimeSec int64

AbsoluteTimeSec is time in milliseconds since the Unix epoch

func FromTimeSec

func FromTimeSec(tm time.Time) AbsoluteTimeSec

func (AbsoluteTimeSec) ToTime

func (at AbsoluteTimeSec) ToTime() time.Time

func (AbsoluteTimeSec) ToUnix

func (at AbsoluteTimeSec) ToUnix() int64

type Cleaner

type Cleaner[T any] struct {
	// contains filtered or unexported fields
}

func NewCleanup0

func NewCleanup0(cl func()) *Cleaner[bool]

func NewCleanup1

func NewCleanup1[T any](cl func() T) *Cleaner[T]

func (*Cleaner[T]) Cleanup

func (c *Cleaner[T]) Cleanup()

func (*Cleaner[T]) Disarm

func (c *Cleaner[T]) Disarm()

type EditorFunc

type EditorFunc[V any] func(value V, present bool) (newValue V, newPresent bool)

type MutableContext

type MutableContext struct {
	// contains filtered or unexported fields
}

type MutableContextKey

type MutableContextKey[V any] struct {
	// contains filtered or unexported fields
}

func NewMutableContextKey

func NewMutableContextKey[V any](name string) MutableContextKey[V]

Jump to

Keyboard shortcuts

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