std

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

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

Go to latest
Published: Oct 31, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcEveryPageNumber

func CalcEveryPageNumber(count, size, index int) (start, end int)

CalcEveryPageNumber returns a page start, end numbers by count, size, index.

func ConvertBasicType

func ConvertBasicType(value string, objType reflect.Type, objValue reflect.Value) error

ConvertBasicType 根据obj的反射类型、值,将value设置给obj。

func CurrentFuncName

func CurrentFuncName() string

func FilterExistingIPsInSubnets

func FilterExistingIPsInSubnets(ipSources, ipSubnets []string) (result []string, err error)

FilterExistingIPsInSubnets 过滤存在IP网段中的ip

func FilterPrivateIPs

func FilterPrivateIPs(ips []string) []net.IP

FilterPrivateIPs 过滤出私有IP地址

func FindStrInSlice

func FindStrInSlice(list []string, str string) int

func GetFuncName

func GetFuncName(fn interface{}) string

func GetLocalHostIP

func GetLocalHostIP() string

GetLocalHostIP returns local IP addr.

func GetMD5

func GetMD5(data string) string

func GetRootDomainName

func GetRootDomainName(domainName string) string

GetRootDomainName 获取域名的根域名,如果pulicsuffix获取没有出错,返回eTLD,否则使用正则获取

func GetRootDomainNameByRegexp

func GetRootDomainNameByRegexp(domainName string) string

GetRootDomainNameByRegexp 使用正则获取域名的要域名

func GetWildcardDomain

func GetWildcardDomain(domainName string) string

func GetWorkDir

func GetWorkDir() string

func IPInSubnet

func IPInSubnet(ip net.IP, subnet *net.IPNet) bool

IPInSubnet 检查单个IP是否在子网内

func IPsInSubnets

func IPsInSubnets(ips []string, subnets []string) (map[string][]bool, error)

IPsInSubnets 检查多个IP地址段包含多个IP地址

func InterStringSlice

func InterStringSlice(s1 []string, s2 []string) []string

func IsLetterOrNumber

func IsLetterOrNumber(str string) bool

func IsValidDomainName

func IsValidDomainName(domainName string) bool

func IsWildcardDomain

func IsWildcardDomain(domainName string) bool

func JSONConvert

func JSONConvert(from any, to any) error

JSONConvert uses json Marshal, Unmarshal to copy.

func JSONDump

func JSONDump(val any) string

JSONDump returns json Marshal string of val.

func LowerFirstChar

func LowerFirstChar(letter string) string

func MakeNotExists

func MakeNotExists(dir string)

MakeNotExists 判断目录是否存在,若不存在,则创建目录

func ParentFuncName

func ParentFuncName() string

func ParentFuncNameAndFileLine

func ParentFuncNameAndFileLine() string

ParentFuncNameAndFileLine 获取调用者的详细信息,包括函数名、文件名及行数

func ParentFuncShortName

func ParentFuncShortName() string

func ParseLocalDate

func ParseLocalDate(dateStr string) (t time.Time, err error)

func ParseLocalTime

func ParseLocalTime(timeStr string) (t time.Time, err error)

func ParsePages

func ParsePages(pageSize, pageIndex int) (int, int)

ParsePages returns page size [1,500] and index [1,]

func ParsePagesFroLarge

func ParsePagesFroLarge(pageSize, pageIndex int) (int, int)

ParsePagesFroLarge returns page size [1,5000] and index [1,]

func ParsePagesWithLimit

func ParsePagesWithLimit(pageSize, pageIndex, pageSizeLimit int) (int, int)

ParsePagesWithLimit returns page size [1,pageSizeLimit] and index [1,]

func ParseRange

func ParseRange(count, pageSize, pageIndex int) (int, int)

ParseRange returns a page start, end numbers by count, size, index.

func ParseRangeForLarge

func ParseRangeForLarge(count, pageSize, pageIndex int) (int, int)

ParseRangeForLarge returns a page start, end numbers by count, size, index.

func ParseRangeWithLimit

func ParseRangeWithLimit(count, pageSize, pageIndex, pageSizeLimit int) (int, int)

ParseRangeWithLimit returns a page start, end numbers by count, size, index.

func RandStr

func RandStr(n int) string

RandStr 生成固定位数对随机值

func RemoveDuplicateStringList

func RemoveDuplicateStringList(tem []string) []string

func RemoveDuplicateStringSlice

func RemoveDuplicateStringSlice(tmp []string) []string

func RemoveStringSlice

func RemoveStringSlice(s []string, removed []string) []string

func ReverseStr

func ReverseStr(str string) string

func SafeGo

func SafeGo(run func())

func SecureRandomInt

func SecureRandomInt(min, max int) int

SecureRandomInt 使用crypto/rand生成安全的随机数 crypto/rand生成的随机数不容易被预测, 但相比math/rand,可能在性能上稍微慢一些,因为使用了操作系统的随机数生成器。

func SplitDomainBySpecifyLevel

func SplitDomainBySpecifyLevel(domainName string, level int) ([]string, error)

SplitDomainBySpecifyLevel 将域名按指定层级拆分,形成泛域名+域名集合

func SplitFuncName

func SplitFuncName(fn string, separator ...rune) string

func Stringify

func Stringify(v ...any) string

func TimeFormat

func TimeFormat(t time.Time) string

func UnionStringSlice

func UnionStringSlice(s1, s2 []string) []string

func UpperFirstChar

func UpperFirstChar(letter string) string

func ValidIPAddr

func ValidIPAddr(ip string) bool

ValidIPAddr reports whether a valid ip addr.

func ValidJSON

func ValidJSON(str string) bool

ValidJSON checks whether a str is JSON object, {} or [].

func ValidURLHostIpAddr

func ValidURLHostIpAddr(urlStr string, ipAddrList ...string) string

ValidURLHostIpAddr 读取URL中的Host IP地址的有效信息 如果无效信息或解析错误(url.Parse错误、不是ipv4、不是ipv6、不是有效的域名),则返回空字符串

func WritePidToFile

func WritePidToFile(pidFile string)

Types

This section is empty.

Jump to

Keyboard shortcuts

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