Please check out the Golang toolset if you find it helpful
Own toolset project. Continuously updated…
Project address github.com/wangxudong1…
v1.2.0
STR package increment method
-
Capitalize func Capitalize(STR string) String
-
Func IsStartUpper(s string) bool
v1.1.0
increasenumber
package
Numeric type conversion
-
Func StringToFloat64(Value String) (f float64)
-
Float64 func Int64ToFloat64(value int64) (f float64)
-
String to Float64Func StringToInt64(Value String) (I int64)
-
Intfunc StringToInt(value string) (int)
-
Func Float64ToInt64(Value Float64ToInt64) (I int64)
-
Float64ToString(Value Float64) (s String)
-
Int64 to stringFunc Int64ToString(value int64) (s string)
-
Float64 func IntToFloat64(value int) (f float64)
Dealing with decimal places
- Reserved decimal place
func RoundFloat64(value float64, exp int) (num float64)
Number of digits reserved by exp
Floating-point numeric comparison
-
Func (c Cmp) Equal(l, r FLOAT64) bool
res := Cpm.Equal(3.3) t.Log(res) //true Copy the code
-
Func (c Cmp) Greater(L, r FLOAT64) bool
-
Func (c Cmp) Smaller(l, r float64) bool
-
Func (c Cmp) GreaterOrEqual(l, r FLOAT64) bool
-
Func (c Cmp) SmallerOrEqual(l, r FLOAT64) bool
The sorting
-
Initialize array func NewNumbers(n… interface{}) number
/ / array can contain float64 float32, int, int64, int32 NewNumbers(3.44.3453.float64(4.999999999), float64(2.0000001)) Copy the code
-
Find the maximum value func (n number) Max() float64
max := NewNumbers(3.44.3453.float64(4.999999999), float64(2.0000001)).Max() t.Log(max) / / 3453 Copy the code
-
Find the minimum value func (n number) Min() float64
min := NewNumbers(3.44.3453.float64(4.999999999), float64(2.0000001)).Min() t.Log(min)/ / 2.0000001 Copy the code
-
Func (n number) OrderDesc() []interface{}
The element type of the returned array is the original type, uncast
desc := NewNumbers(3.44.3453.float64(4.999999999), float64(2.0000001)).OrderDesc() t.Log(desc) //[3453 44 4.999999999 3 2.0000001] Copy the code
-
Func (n number) OrderAsc() []interface{}
The element type of the returned array is the original type, uncast
asc := NewNumbers(3.44.3453.float64(4.999999999), float64(2.0000001)).OrderAsc() t.Log(asc)//[2.0000001 3 4.999999999 44 3453] Copy the code
v1.0.1
increasetime
package
Time transformation
-
Create the current time object func NewUnixNow() *theTime
NewUnixNow() Copy the code
-
Create a timestamp object NewUnix(Unix INT64) *theTime
NewUnix(1617264318) Copy the code
-
NewFormat(t string) (*theTime, error)
NewFormat("The 2021-04-01 12:00:00") Copy the code
-
NewISO8601(ISO8601 string) (*theTime, error)
NewIso8601("2019-09-11T01:54:23+00:00") Copy the code
-
Format time func (t *theTime) ToFormat() string
-
Func (t *theTime) ToUnix() int64
-
Func (t *theTime) ToIso8601() string
-
Format theTime using theTime template func (t *theTime) ToFormatForTpl(TPL string) string
V1.0.0 – beta. 1
increasestr
package
Concatenate string methodfunc Join(arg ... interface{}) (string, error)
str.Join(p_int,p_int64,p_string)
Copy the code