utils

package
v0.0.0-...-33c5ed1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DateTimeForDate          = "2006-01-02"
	DatetimeForDateTime      = "2006-01-02 15:04:05"
	DatetimeForShortDateTime = "2006-01-02 15:04"
)

Variables

This section is empty.

Functions

func AddSubjectPrefix

func AddSubjectPrefix(prefix, sub string) string

org增加前缀

func AppendUnique

func AppendUnique(arr []string, s string) []string

func AppendUniqueBatch

func AppendUniqueBatch(arr []string, ss ...string) []string

func Average

func Average(fs []float64, digest ...int) float64

平均值

func CurrTime

func CurrTime() (t int64)

func DateFormat

func DateFormat(t int64, format ...string) string

将时间转为固定格式

func Difference

func Difference(slice1, slice2 []string) []string

求差集 slice1-并集

func Divide

func Divide(f float64, nf float64, digest ...int) float64

func Download

func Download(path string) ([]byte, error)

func ExecStd

func ExecStd(name string, args ...string) ([]byte, error)

func GetFirstDateOfMonth

func GetFirstDateOfMonth(d time.Time) time.Time

获取传入的时间所在月份的第一天,即某月第一天的0点。如传入time.Now(), 返回当前月份的第一天0点时间。

func GetZeroTime

func GetZeroTime(d time.Time) time.Time

获取某一天的0点时间

func InterfaceArrToStringArr

func InterfaceArrToStringArr(ss []interface{}) []string

类型转换(强转)

func Intersect

func Intersect(slice1, slice2 []string) []string

求交集

func KeepFloat

func KeepFloat(f float64, digest ...int) float64

数字保留对应小数(默认6位)

func MD5

func MD5(str string) string

字符串md5加密

func Max

func Max(fs []float64, digest ...int) float64

最大值

func Min

func Min(fs []float64, digest ...int) float64

最小值

func NewHashID

func NewHashID() string

func NowMillion

func NowMillion() (t int64)

func NumberToString

func NumberToString(f float64) string

避免科学计数法的数字转文本

func ObjectBsToStringArr

func ObjectBsToStringArr(obj interface{}, def ...string) []string

func ObjectToFloat64

func ObjectToFloat64(obj interface{}, def ...float64) float64

接口对象转为float64

func ObjectToInt

func ObjectToInt(obj interface{}, def ...int) int

接口对象转为int

func ObjectToInt64

func ObjectToInt64(obj interface{}, def ...int64) int64

接口对象转为int64

func ObjectToMap

func ObjectToMap(obj interface{}) (res map[string]interface{})

func ObjectToMapArr

func ObjectToMapArr(obj interface{}) (res []map[string]interface{})

func ObjectToString

func ObjectToString(obj interface{}, def ...string) string

func ObjectToStringArr

func ObjectToStringArr(obj interface{}) []string

func StrArrayDeal

func StrArrayDeal(strA []string) []string

字符串数组去重去空

func StrArrayIncludes

func StrArrayIncludes(strA []string, s string) bool

include

func StrArrayIndexOf

func StrArrayIndexOf(strA []string, s string) int

func StrArrayUnique

func StrArrayUnique(strA []string) []string

字符串数组去重

func StrToFloat64

func StrToFloat64(s string, def ...float64) float64

字符串转为float64

func StrToInt

func StrToInt(s string, def ...int) int

字符串转为int

func StrToInt64

func StrToInt64(s string, def ...int64) int64

字符串转为int64

func Sum

func Sum(fs []float64, digest ...int) float64

求和

func ToDatetime

func ToDatetime(t int64) time.Time

将标准毫秒数转为时间

func Union

func Union(slice1, slice2 []string) []string

Types

type Filter

type Filter struct {
	PageSize     int    `json:"page_size"`
	CurrPage     int    `json:"curr_page"`
	Offset       int    `json:"offset" `
	ParentID     int    `json:"parent_id"`
	DepartmentID int    `json:"department_id"`
	UserID       string `json:"user_id" `
	Type         int    `json:"type" ` // 部门: 0 部门列表 1 角色列表
	IsGroup      bool   `json:"is_group"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL