40 lines
804 B
Go
40 lines
804 B
Go
package commonUtils
|
|
|
|
import "context"
|
|
|
|
type Task func(ctx context.Context) error
|
|
|
|
// Number types
|
|
type (
|
|
Signed interface {
|
|
~int | ~int8 | ~int16 | ~int32 | ~int64
|
|
}
|
|
Unsigned interface {
|
|
~uint | ~uint8 | ~uint32 | ~uint64
|
|
}
|
|
Float interface{ ~float32 | ~float64 }
|
|
Int interface{ Signed | Unsigned }
|
|
Num interface{ Float | Int }
|
|
)
|
|
|
|
type IRange[T Num] interface {
|
|
Begin() T
|
|
End() T
|
|
}
|
|
|
|
type Range[T Num] struct {
|
|
IRange[T]
|
|
begin T
|
|
end T
|
|
}
|
|
|
|
func NewRange[T Num](begin T, end T) *Range[T] { return &Range[T]{begin: begin, end: end} }
|
|
func (r Range[T]) Begin() T { return r.begin }
|
|
func (r Range[T]) End() T { return r.end }
|
|
|
|
type CovertFunc[Tin any, Tout any] func(in Tin) (out Tout, err error)
|
|
|
|
type IStrConvertable interface {
|
|
String() string
|
|
}
|