Categorygithub.com/scrawld/util
modulepackage
0.1.5
Repository: https://github.com/scrawld/util.git
Documentation: pkg.go.dev

# README

util

Some commonly used functions

# Packages

No description provided by the author
No description provided by the author

# Functions

* * Assign 结构体赋值 * * Example: * * type User1 struct { * Name string * Age int * } * * type User2 struct { * Name string * Age int * } * * u1 := &User1{Name: "zhangsan", Age: 20} * u2 := &User2{} * * Assign(u1, u2) * fmt.Println(u1, u2) */.
No description provided by the author
max-min=days DtSub(20200302, 20200301) = 1.
* * ExportExcel 生成excel * * Example: * * type ReportExcel struct { * Dt string `excel:"日期"` * NewUsers int64 `excel:"注册人数"` * LoginUsers int64 `excel:"登录人数"` * Tmp int64 `excel:"-"` * } * tbody := []ReportExcel{ * {"2006-01-02", 1, 2}, * } * buf, err := ExportExcel(ReportExcel{}, tbody) * if err != nil { * // * } * ioutil.WriteFile("test.xlsx", buf.Bytes(), 0644) */.
获取指定日期零点时间.
获取日期到小时 GetDataHour(time.Now()) return 2022122609.
获取日期范围 GetDataHourRange(1672012800, 1672027997) ruturn []int{2022122608 2022122609 2022122610 2022122611 2022122612}.
获取日期 GetDtByOffset(time.Now(), 0) return 20060102.
日期范围 GetDtRange(20200101, 20200203) ruturn []int{20200101,20200102,20200103}.
获取周次 GetDtRange(time.Unix(1672588800, 0)) return 2023.1.
获取时间范围内的周次 GetWeekRange(1671790242, 1672588800) return []string{"2022.51", "2022.52", "2023.1"}.
InSlice 函数搜索数组中是否存在指定的值.
InSliceF 函数搜索数组中是否存在指定的值.
ParseTagSetting get model's field tags.
No description provided by the author
RandNum.
* * ReadExcelToStruct 读取excel到结构体 * * Example: * * type ReportExcel struct { * Dt string `excel:"日期"` * NewUsers int64 `excel:"注册人数"` * LoginUsers int64 `excel:"登录人数"` * Tmp int64 `excel:"-"` * } * * records, err := ReadExcelToStruct("test.xlsx", ReportExcel{}) * if err != nil { * // * } * fmt.Println(records) */.
SliceChunk 函数把一个数组分割为新的数组块.
SliceChunkInt64.
SliceDiff 函数用于比较两个数组的值,并返回差集.
SliceDiff 函数用于比较两个数组的值,并返回差集.
SliceShuffle 函数把数组中的元素按随机顺序重新排列.
SliceUnique 函数用于移除数组中重复的值.
SliceUniqueInt.
SliceUniqueInt32.
StructDiff.