util

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApplicationJSON = "application/json"
	XmlForm         = "application/x-www-form-urlencoded;charset=utf-8"
)
View Source
const DayEnd = "23:59:59"
View Source
const DayStart = "00:00:00"

Variables

This section is empty.

Functions

func Add

func Add(date time.Time, d int64) time.Time

func AddDate

func AddDate(date time.Time, d int) time.Time

func AddFloat64

func AddFloat64(a *float64, b *float64) *float64

AddFloat64 精度加法 a+b

func Addr

func Addr[T any](p T) *T

func AppendDeduplicate added in v0.0.6

func AppendDeduplicate[T comparable](slice []T, elems T) []T

func AppendDeduplicateCanNull added in v0.0.9

func AppendDeduplicateCanNull[T comparable](slice []T, elems T) []T

func AppendForSplitComma added in v0.0.14

func AppendForSplitComma(list, item string) string

func Args

func Args(i int) string

func ArrayContains

func ArrayContains[T comparable](array []T, e T) bool

func ContainsForSplitComma

func ContainsForSplitComma(list, item string) bool

func DifferenceSet

func DifferenceSet[K comparable](a1, a2 []K) (d1, d2 []K)

func DivideFloat64

func DivideFloat64(a *float64, b *float64) *float64

DivideFloat64 精度除法 a/b

func End

func End(date time.Time) time.Time

func FandomString

func FandomString(strlen int) string

func FormatDate

func FormatDate(dateTime time.Time) string

func FormatDateMillTime

func FormatDateMillTime(dateTime time.Time) string

func FormatDateTime

func FormatDateTime(dateTime time.Time) string

FormatDateTime 格式 yyyy-MM-dd HH:mm:ss

func FormatDates

func FormatDates(dateTime time.Time) string

func FormatFloat32

func FormatFloat32(f float32) string

FormatFloat32 将多余的浮点格式化

func FormatFloat64

func FormatFloat64(f float64) string

FormatFloat64 将多余的浮点格式化

func Get

func Get(client http.Client, apiUrl string, params url.Values) ([]byte, error)

func GetGID

func GetGID() uint64

func GetHeader

func GetHeader(client http.Client, apiUrl string, params url.Values, header map[string]string) ([]byte, error)

func GetInterfaceToString

func GetInterfaceToString(value interface{}) string

func HideString added in v0.0.27

func HideString(orgStr *string, preFixLength, postFixLength, minLength int) string

HideString 脱敏字符串 * orgStr 原字符串 preFixLength 前面不脱敏字符长度 postFixLength 后面不脱敏字符长度 minLength 需要脱敏字符串最小长度,如果没满足按照字符串长度全脱敏 stringType 字符串类型 1:普通字符,2:带有中午特殊字符

func If

func If[K any](isTrue bool, a, b K) K

func IfNull

func IfNull[K any](a *K, defaultValue K) K

func IsEmpty

func IsEmpty(s *string) bool

func IsNil

func IsNil(i interface{}) bool

func Md5

func Md5(s string) string

func MilSecond

func MilSecond(time time.Time) int64

获取13位毫秒的时间戳

func MultiplyFloat64

func MultiplyFloat64(a *float64, b *float64) *float64

MultiplyFloat64 精度乘法 axb

func Param

func Param(c *gin.Context, key string) string

func ParamInt

func ParamInt(c *gin.Context, key string) int

func ParamInt16

func ParamInt16(c *gin.Context, key string) int16

func ParamInt32

func ParamInt32(c *gin.Context, key string) int32

func ParamInt64

func ParamInt64(c *gin.Context, key string) int64

func ParamInt8

func ParamInt8(c *gin.Context, key string) int8

func ParamUint16

func ParamUint16(c *gin.Context, key string) uint16

func ParamUint32

func ParamUint32(c *gin.Context, key string) uint32

func ParamUint64

func ParamUint64(c *gin.Context, key string) uint64

func ParamUint8

func ParamUint8(c *gin.Context, key string) uint8

func ParseDate added in v0.0.4

func ParseDate(date string) time.Time

func ParseDateEnd

func ParseDateEnd(date string) time.Time

func ParseDateStart

func ParseDateStart(date string) time.Time

func ParseDateTime

func ParseDateTime(dateTime string) time.Time

func ParseDateTimeE

func ParseDateTimeE(dateTime string, errMsg string) time.Time

func PostFormStr

func PostFormStr(client http.Client, url string, params string, header map[string]string) ([]byte, error)

func PostJSONStr

func PostJSONStr(client http.Client, url string, params string, header map[string]string) ([]byte, error)

func PostJson

func PostJson(client http.Client, url string, params interface{}) ([]byte, error)

func PostJsonHeader

func PostJsonHeader(client http.Client, url string, params interface{}, header map[string]string) ([]byte, error)

func Second

func Second(time time.Time) int64

获取10位秒的时间戳

func SortKeys

func SortKeys(orgMap map[string]interface{}) []string

func SpanDays added in v0.0.5

func SpanDays(startDateTime, endDateTime *time.Time) int

SpanDays 计算两时间跨度多少天

func SpanMinute added in v0.0.5

func SpanMinute(startDateTime, endDateTime *time.Time) int

SpanMinute 计算两时间跨度多少分钟

func SpanMonths added in v0.0.5

func SpanMonths(startDateTime, endDateTime *time.Time) (month int)

SpanMonths 计算两时间跨度多少个月(例如:2000-01-01到2000-06-01跨度6个月)

func Start

func Start(date time.Time) time.Time

func StrToMap

func StrToMap(obj string) map[string]interface{}

func StrToMapStr

func StrToMapStr(obj string) map[string]string

func StrToUrlValue

func StrToUrlValue(obj string) url.Values

func SubtractFloat64

func SubtractFloat64(a *float64, b *float64) *float64

SubtractFloat64 精度减法 a-b

func TimeSubMinute

func TimeSubMinute(endDateTime, startDateTime *time.Time) int

TimeSubMinute 计算两时间相差分钟数(向上取整)

func TimeSubMinuteFloor

func TimeSubMinuteFloor(endDateTime, startDateTime *time.Time) int

TimeSubMinuteFloor 计算两时间相差分钟数(向下取整)

func ToMap

func ToMap(obj interface{}) map[string]interface{}

func ToObject

func ToObject(txt string, p interface{}) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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