Documentation ¶
Index ¶
- func AscSorted[T constraints.Ordered](s []T) []T
- func BytesFromURL(ctx context.Context, rawUrl string) ([]byte, error)
- func CoarseTimestamp() float64
- func CompareHumanizeString(a, b string) int
- func DescSorted[T constraints.Ordered](s []T) []T
- func HitIndexes[T any](collection []T, missIndexes []int) []int
- func IntSliceContains(ints []int, n int) bool
- func IsGhostInterface(i interface{}) bool
- func JsonString(v interface{}) string
- func MapKeys2Slice[K comparable, V any](m map[K]V) []K
- func MapValues2Slice[K comparable, V any](m map[K]V) []V
- func ParseDataUrls(rawURL string) (mediaType string, isBase64 bool, data []byte, err error)
- func SliceContains[T comparable](s []T, a T) bool
- func StringFromURL(ctx context.Context, rawUrl string) (string, error)
- func StringSliceContains(strs []string, str string) bool
- func SubstringsWithTags(str, startTag, endTag string) []string
- func UnduplicatedSlice[T comparable](s []T) []T
- func ValidateStruct(ctx context.Context, s interface{}) error
- type Stack
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesFromURL ¶
BytesFromURL 从url获得数据。 支持的scheme:file://、http://、https://、data:。 url示例:file:///etc/fstab、data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==。
func CompareHumanizeString ¶
CompareHumanizeString 比较两个字符串,结果接近可视结果。
func HitIndexes ¶
HitIndexes 根据未命中的索引,得到命中的索引
func IntSliceContains ¶
IntSliceContains []int是否包含一个指定的int值。
func IsGhostInterface ¶
func IsGhostInterface(i interface{}) bool
IsGhostInterface 判断接口是否为nil,或者指向指针是否为空。 使用指向空指针的接口去调函数,会panic。
func JsonString ¶
func JsonString(v interface{}) string
JsonString 序列化为json,并转为字符串返回。如果序列化失败,返回空字符串。
func MapKeys2Slice ¶
func MapKeys2Slice[K comparable, V any](m map[K]V) []K
MapKeys2Slice 提取map的key组成切片返回。
func MapValues2Slice ¶
func MapValues2Slice[K comparable, V any](m map[K]V) []V
MapValues2Slice 提取map的value组成切片返回。
func ParseDataUrls ¶
ParseDataUrls 解析Data Urls。 协议参考:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs 、 https://en.wikipedia.org/wiki/Data_URI_scheme。 格式:data:[<mediatype>][;base64],<data>
func StringFromURL ¶
StringFromURL 从url获得字符串。 支持的scheme:file://、http://、https://、data:。 url示例:file:///etc/fstab、data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==。
func StringSliceContains ¶
StringSliceContains []string是否包含一个指定的string值。
func SubstringsWithTags ¶
SubstringsWithTags 根据前后标签,找出子字符串。 比如字符串为“我是一名{[(程序员)]}”,前后标签为“{[(”和“)]}”,匹配的字符串为“程序员”。 返回元素顺序同它们在字符串内的顺序。 如果存在重复的匹配子字符串,函数返回元素也将重复。
func UnduplicatedSlice ¶
func UnduplicatedSlice[T comparable](s []T) []T
UnduplicatedSlice 返回一个新的元素不重复的切片,新切片保留元素顺序。
func ValidateStruct ¶
ValidateStruct 校验结构体对象字段值。 依赖于字段validate标签。校验支持:https://github.com/go-playground/validator。
Types ¶
type Stack ¶
Stack 调用栈。
func CaptureStack ¶
CaptureStack 捕获调用栈。 skip为0表示栈从CaptureStack开始,为1表示栈从CaptureStack的调用者开始。