helper

package
v0.0.0-...-8d65813 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CeilFloat

func CeilFloat(val float64, precision int) float64

向上取整保留小数

func ConvertToMap

func ConvertToMap(str string, length int64) ([]map[string]string, error)

转换为 map

func ConvertToSlice

func ConvertToSlice(str string, length int64) ([]string, error)

转换为切片

func Diff

func Diff(elems []string, a ...[]string) []string

返回 elems 里排除 a 的项,保证顺序

func Filter

func Filter(elems []string, fn func(a string) bool) []string

过滤列表

func FloorFloat

func FloorFloat(val float64, precision int) float64

向下取整保留小数

func InArray

func InArray(needle string, arr []string) bool

判断是否在 []string 里

func Intersect

func Intersect(a, b []string) []string

取元素交集,以 a 的顺序为准

func Mask

func Mask(str string) string

掩码

func Merge

func Merge(a ...[]string) []string

合并元素,保证顺序

func ParseDate

func ParseDate(t string) *time.Time

解析日期字符串

func ParseTime

func ParseTime(t string) *time.Time

解析时间字符串

func PastTime

func PastTime(p time.Time) string

几天前

func RemoveHTMLTags

func RemoveHTMLTags(htmlStr string) string

移除 html 标签

func RoundFloat

func RoundFloat(val float64, precision int) float64

四舍五入保留小数

func Shuffle

func Shuffle(arr []string)

打乱顺序

func ToMap

func ToMap(elems []string) map[string]struct{}

转为 map

func Unique

func Unique(elems []string) []string

去除重复项

Types

This section is empty.

Jump to

Keyboard shortcuts

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