nettools/common/types.go

40 lines
805 B
Go
Raw Normal View History

2024-11-12 08:10:09 +00:00
package common_utils
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
}