-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
compatability.go
40 lines (34 loc) · 970 Bytes
/
compatability.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package utils
import "github.com/Laisky/go-utils/v5/common"
// Number is a number type
type Number common.Number
// Sortable Data types that can be compared by >, <, ==
type Sortable common.Sortable
var (
// AbsInt64 abs(v)
//
// ignore int exceeds limit error, abs(MinInt64) == MaxInt64
AbsInt64 = common.AbsInt64
// AbsInt32 abs(v)
//
// ignore int exceeds limit error, abs(MinInt32) == MaxInt32
AbsInt32 = common.AbsInt32
// Round round float64
//
// Round(1.005, 2) -> 1.01
Round = common.Round
// HumanReadableByteCount convert bytes to human readable string
//
// Args:
// - bytes:
// - si: `si ? 1024 : 1000`
//
// Example:
//
// `HumanReadableByteCount(1005, false) -> "1.01KB"`
HumanReadableByteCount = common.HumanReadableByteCount
)
// Min return the minimal value
func Min[T Sortable](vals ...T) T { return common.Min(vals...) }
// Max return the maximal value
func Max[T Sortable](vals ...T) T { return common.Max(vals...) }