Documentation
¶
Index ¶
- func AutoRetry[T any](ctx context.Context, supplier func() (T, error), maxRetryTimes int, ...) (T, error)
- func CombineFileName(base string, ext string) string
- func CopyToFileWithBuffer(ctx context.Context, out *os.File, in io.Reader, buffer []byte, chunkSize int, ...) (written int64, err error)
- func GetFileExtensionFromUrl(rawUrl string) (string, error)
- func IsErrorOfType(err, target error) bool
- func Max[T Number](t1 T, t2 T) T
- func Min[T Number](t1 T, t2 T) T
- func PrettyBytes(b uint64) string
- type Number
- type Opt
- type OptError
- type OptNull
- type OptZero
- type RoomId
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AutoRetry ¶
func AutoRetry[T any]( ctx context.Context, supplier func() (T, error), maxRetryTimes int, retryInterval time.Duration, logger *logging.Logger) (T, error)
AutoRetry retries the supplier automatically, with given time limit and interval. If maximum retry time limit is reached and the supplier still fails, the last error will be returned. If logger is not nil, retry information will be printed to it.
func CombineFileName ¶ added in v0.2.0
func CopyToFileWithBuffer ¶
func CopyToFileWithBuffer( ctx context.Context, out *os.File, in io.Reader, buffer []byte, chunkSize int, syncFile bool, ) (written int64, err error)
CopyToFileWithBuffer copies data from io.Reader to os.File with given buffer and read chunk size. The reader and file won't be closed. If syncFile is set, the file will be synced after every read.
func GetFileExtensionFromUrl ¶
GetFileExtensionFromUrl copied from https://elisegev.medium.com/get-a-file-extension-from-a-url-in-golang-5061d4a298a
func IsErrorOfType ¶
IsErrorOfType is a modified version of errors.Is, which loosen the check condition
func PrettyBytes ¶
Types ¶
type Number ¶
type Number interface {
constraints.Integer | constraints.Float
}
Click to show internal directories.
Click to hide internal directories.