Documentation
¶
Overview ¶
Package ena provide the utility for golang.
Index ¶
- Variables
- func ByteOrder() binary.ByteOrder
- func EnforcePtr(obj interface{}) (reflect.Value, error)
- func IndirectToSetableValue(i interface{}) (reflect.Value, error)
- func IndirectToValue(v interface{}) reflect.Value
- func PointerTo[T any](v T) *T
- func ReceiveChannel[T any](ctx context.Context, ch <-chan interface{}) (v T, err error)
- func ValueTo[T any](p *T) (v T)
- func ValueToOrDefault[T any](p *T, d T) (v T)
- type FnOption
- type NoCopy
- type Option
- type WaitGroupWrapper
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnexpectPointer represent the obj is not an expected pointer type or value ErrUnexpectPointer = xerrors.Errorf("UnexpectPointer") )
Functions ¶
func EnforcePtr ¶
EnforcePtr ensures that obj is a pointer of some sort. Returns a reflect.Value of the dereferenced pointer, ensuring that it is settable/addressable. Returns an error if this is not possible.
func IndirectToSetableValue ¶
IndirectToSetableValue returns the setable reflect.Value of i
func IndirectToValue ¶
IndirectToValue returns the reflect.Value of v If the interface is non reflect.Value, return the reflect.ValueOf(v)
func ReceiveChannel ¶
ReceiveChannel consume obj from channel, it will: 1. return err if ctx is Done 2. return err is obj is error 3. return err if obj is not error or type T
func ValueTo ¶
func ValueTo[T any](p *T) (v T)
ValueTo returns a value for the passed pointer. If the pointer is nil, will return the empty value of T.
func ValueToOrDefault ¶
func ValueToOrDefault[T any](p *T, d T) (v T)
ValueToOrDefault returns a value for the passed pointer. If the pointer is nil, will return the default value.
Types ¶
type FnOption ¶
type FnOption[T any] struct { Fn func(*T) }
FnOption is an generic function helper for Option
type NoCopy ¶
type NoCopy struct{}
NoCopy may be embedded into structs which must not be copied after the first use.
See https://github.com/golang/go/issues/8005#issuecomment-190753527 for details.
type Option ¶
type Option[T any] interface { // Apply applies this configuration to the given option Apply(*T) }
Option is an generic configuration helper
func NewFnOption ¶
NewFnOption will instant an Option with f
type WaitGroupWrapper ¶
type WaitGroupWrapper struct { NoCopy // contains filtered or unexported fields }
WaitGroupWrapper is a help struct for sync.WaitGroup
func (*WaitGroupWrapper) Wait ¶
func (w *WaitGroupWrapper) Wait()
Wait will block until all cb finished
func (*WaitGroupWrapper) Wrap ¶
func (w *WaitGroupWrapper) Wrap(cb func(), cbs ...func())
Wrap will handle sync.WaitGroup Add and Done
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package main is the entrance of project
|
Package main is the entrance of project |
Package conma provide the machinism to load config from env、flag、file and configuration system.
|
Package conma provide the machinism to load config from env、flag、file and configuration system. |
examples
Package main provide an example for use conma to retrieve configuration items
|
Package main provide an example for use conma to retrieve configuration items |
Package conv provide the helper function to convert data types & string
|
Package conv provide the helper function to convert data types & string |
Package delayqueue describe an delayqueue implemention.
|
Package delayqueue describe an delayqueue implemention. |
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
pkg
|
|
utils/version
Package version provide the information of current project module
|
Package version provide the information of current project module |
Package priorityqueue describe an prioriry queue implement.
|
Package priorityqueue describe an prioriry queue implement. |
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
Package test contains some helper function for unittest and e2e-test
|
Package test contains some helper function for unittest and e2e-test |
Package timingwheel implementation of Hierarchical Timing Wheels.
|
Package timingwheel implementation of Hierarchical Timing Wheels. |
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
Package wait provides utility functions for polling, listening using Go channel
|
Package wait provides utility functions for polling, listening using Go channel |
Package xerrors contains the utility for errors.
|
Package xerrors contains the utility for errors. |
Package xslog provide some helper for slog package.
|
Package xslog provide some helper for slog package. |
Package xtime contains the utility for time.
|
Package xtime contains the utility for time. |