tools

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

用于slice 去重 及 检查元素是否存在于 slice 中 去重,支持 booleans, numbers, strings, pointers, channels, arrays of comparable types

t := Unique(s []T)

元素检查,支持 booleans, numbers, strings, pointers, channels, arrays of comparable types

in:= IsExists(s []T)
ok := in(a)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Action added in v0.0.4

func Action(method, surl string, headers map[string]string, data any, timeout time.Duration) (http_code int, res []byte, err error)

func AtosSlice

func AtosSlice(a []any) []string

[]any{} 转 []string{}

func Conform added in v0.0.2

func Conform(s string) bool

func Delete added in v0.0.4

func Delete(surl string, headers map[string]string, data any, timeout time.Duration) (http_code int, res []byte, err error)

func Difference

func Difference[T comparable](a, b []T) ([]T, []T)

取两个切片的差集

func Get added in v0.0.4

func Get(surl string, headers map[string]string, data map[string]string, timeout time.Duration) (http_code int, res []byte, err error)

func GetStructKeys

func GetStructKeys(s any, tag string) ([]string, error)

根据标签取出结构体所有key

func Intersection

func Intersection[T comparable](a, b []T) []T

取两个切片的交集

func IsExists

func IsExists[T comparable](s []T) func(v T) bool

func MatchCN added in v0.0.2

func MatchCN(s string) bool

正则匹配,允许包含中文

func Post added in v0.0.4

func Post(surl string, headers map[string]string, data any, timeout time.Duration) (http_code int, res []byte, err error)

func Put added in v0.0.4

func Put(surl string, headers map[string]string, data any, timeout time.Duration) (http_code int, res []byte, err error)

func StructToMap

func StructToMap(object interface{}, tagName string) (map[string]interface{}, error)

结构体转 map[string]interface{}

func Union

func Union[T comparable](a, b []T) []T

取两个切片的并集

func Unique

func Unique[T comparable](s []T) []T

Types

This section is empty.

Jump to

Keyboard shortcuts

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