Documentation
¶
Index ¶
- Variables
- func AutoParseTimeFromString(raw string) (result time.Time, layout string, err error)
- func BytesFromat(raw uint64) float64
- func CheckWritePermission(dir string) error
- func ComparePaths(path1, path2 string) (bool, error)
- func Compress(data []byte, algorithm string) ([]byte, error)
- func CompressWithFlate(data []byte) ([]byte, error)
- func CompressWithGzip(data []byte) ([]byte, error)
- func CompressWithLzw(data []byte) ([]byte, error)
- func CompressWithZlib(data []byte) ([]byte, error)
- func CreateDirIFNotExist(dir string) (err error)
- func CreateFileIFNotExist(file string) (absolute string, err error)
- func DSNIsMemory(dsn string) bool
- func Decimal(value float64, precision int) float64
- func DistinctStringSlice2String(raw []string, symbol string) string
- func DistinctStringSlice2StringSlice(raw []string) []string
- func ExecuteCommand(command string, args string) (table map[string]string, err error)
- func FileIsExist(file string) (path string, err error)
- func FrequencyFormat(raw float64) float64
- func GetARPTable() (table map[string]string, err error)
- func GetAllIPsInSubnetExceptSelf(ipNet *net.IPNet) ([]net.IP, error)
- func GetCurrentMonth() int32
- func GetCurrentMonthDay() int32
- func GetCurrentMonthWeek() int32
- func GetCurrentMonthWorkDay() int32
- func GetCurrentQuarter() int32
- func GetCurrentQuarterDay() int32
- func GetCurrentQuarterWeek() int32
- func GetCurrentTime() time.Time
- func GetCurrentTimezoneAndOffset() (string, int32)
- func GetCurrentUTCMonth() int32
- func GetCurrentUTCMonthDay() int32
- func GetCurrentUTCMonthWeek() int32
- func GetCurrentUTCMonthWorkDay() int32
- func GetCurrentUTCQuarter() int32
- func GetCurrentUTCQuarterDay() int32
- func GetCurrentUTCQuarterWeek() int32
- func GetCurrentUTCTime() time.Time
- func GetCurrentUTCWeekDay() int32
- func GetCurrentUTCYear() int32
- func GetCurrentUTCYearDay() int32
- func GetCurrentUTCYearWeek() int32
- func GetCurrentUTCYearWorkDay() int32
- func GetCurrentWeekDay() int32
- func GetCurrentYear() int32
- func GetCurrentYearDay() int32
- func GetCurrentYearWeek() int32
- func GetCurrentYearWorkDay() int32
- func GetFileAbsolutePath(file string) (string, error)
- func GetFileRelativePath(file string) (string, error)
- func GetFileRelativeWithoutParentFlagPath(file string) (string, error)
- func GetFileTypeByContent(filename string) (string, error)
- func GetFileTypeBySuffix(filename string) (string, error)
- func GetIPv4Address() (ips []string)
- func GetIPv6Address() (ips []string)
- func GetIneterfaces() ([]net.Interface, error)
- func GetInterfaceByIP(ip net.IP) *net.Interface
- func GetInterfaceIPs(iface *net.Interface, protocol string) ([]net.IP, error)
- func GetLANIPByDNS(address string, timeout time.Duration) net.IP
- func GetLANIPs() []net.IP
- func GetLinuxARPTable() (table map[string]string, err error)
- func GetMACFromIP(ip string) (string, error)
- func GetMacAddress() (macs []string)
- func GetMacByIP(ip string) (string, error)
- func GetMacOSARPTable() (map[string]string, error)
- func GetNode() (ips []string)
- func GetNowTime() (now time.Time, year int32, month int32, day int32, secondTimestamp int64, ...)
- func GetStartNanoTimestamp(start int) int64
- func GetTimestampTime(timestamp int64) time.Time
- func GetUpAndBroadcastAndMulticastAndRunningInterfaces() ([]net.Interface, error)
- func GetUpAndPointtopointAndMulticastAndRunningInterfaces() ([]net.Interface, error)
- func GetUpAndRunningInterfaces() ([]net.Interface, error)
- func GetWindowsARPTable() (map[string]string, error)
- func GobDecode(raw []byte, object any, algorithm string) error
- func GobEncode(object any, compress bool, algorithm string) ([]byte, error)
- func IPToUint(ip net.IP) uint32
- func IsGoFile(filename string) bool
- func IsIPInRange(ip, network, broadcast net.IP) bool
- func IsLANIP(ip net.IP) bool
- func IsLoopbackIP(ip net.IP) bool
- func IsPublicHoliday(t time.Time) bool
- func IsURLEncoded(s string) bool
- func IsURLEncodedByDecoding(s string) bool
- func IsValidMAC(mac string) (string, bool)
- func IsValidStandMAC(mac string) (string, bool)
- func IsWANIP(ip net.IP) bool
- func IsWeekday(t time.Time) bool
- func IsWeekend(t time.Time) bool
- func IsWorkday(t time.Time) bool
- func JsonDecode(raw []byte, object any, algorithm string) error
- func JsonEncode(object any, escape bool, compress bool, algorithm string) ([]byte, error)
- func MDNSSearch(pctx context.Context, serviceType string, timeout time.Duration) (err error)
- func MicrosecondsStatistics(number int64) (years int32, months int32, days int32, hours int32, minutes int32, ...)
- func MillisecondTimestampFormatDaysHoursMinutesSeconds(timestamp float64) (days int32, hours int32, minutes int32, seconds float64)
- func MillisecondsStatistics(number int64) (years int32, months int32, days int32, hours int32, minutes int32, ...)
- func NanosecondsStatistics(number int64) (years int32, months int32, days int32, hours int32, minutes int32, ...)
- func NormalizeMAC(mac string) (string, bool)
- func NormalizePath(p string) (string, error)
- func Number2Float32(value any, precision float32) float32
- func Number2Float64(value any, precision float64) float64
- func Number2Int16(value any, precision int16) int16
- func Number2Int32(value any, precision int32) int32
- func Number2Int64(value any, precision int64) int64
- func Number2Int8(value any, precision int8) int8
- func Number2Uint16(value any, precision uint16) uint16
- func Number2Uint32(value any, precision uint32) uint32
- func Number2Uint64(value any, precision uint64) uint64
- func Number2Uint8(value any, precision uint8) uint8
- func ParseARPCommandOutput(output string) (table map[string]string)
- func ParseAddress(address string) (schema string, host string, ips []net.IP, port int, err error)
- func ParseProcNetARP() (table map[string]string, err error)
- func ParseURLEncodedByDecoding(raw string) string
- func RandomString(length int) string
- func RegexpTrimAllPrefixAndSuffixAsterisk(raw string) string
- func RegexpTrimAllPrefixAndSuffixBackSlash(raw string) string
- func RegexpTrimAllPrefixAndSuffixBackTick(raw string) string
- func RegexpTrimAllPrefixAndSuffixPoint(raw string) string
- func RegexpTrimAllPrefixAndSuffixSlash(raw string) string
- func RegexpTrimAllPrefixAndSuffixSpace(raw string) string
- func RegexpTrimAllPrefixAndSuffixSymbol(raw string, symbol string) string
- func RegexpTrimAllPrefixAsterisk(raw string) string
- func RegexpTrimAllPrefixBackSlash(raw string) string
- func RegexpTrimAllPrefixBackTick(raw string) string
- func RegexpTrimAllPrefixPoint(raw string) string
- func RegexpTrimAllPrefixSlash(raw string) string
- func RegexpTrimAllPrefixSpace(raw string) string
- func RegexpTrimAllPrefixSymbol(raw string, symbol string) string
- func RegexpTrimAllSpace(raw string) string
- func RegexpTrimAllSuffixAsterisk(raw string) string
- func RegexpTrimAllSuffixBackSlash(raw string) string
- func RegexpTrimAllSuffixBackTick(raw string) string
- func RegexpTrimAllSuffixPoint(raw string) string
- func RegexpTrimAllSuffixSlash(raw string) string
- func RegexpTrimAllSuffixSpace(raw string) string
- func RegexpTrimAllSuffixSymbol(raw string, symbol string) string
- func RemoveStringSliceElement(raw []string, elements ...string) []string
- func SecondsStatistics(number int64) (years int32, months int32, days int32, hours int32, minutes int32, ...)
- func TimestampFormat(timestamp int64, layout string) string
- func TimestampParse(timestamp int64) (year int, month int, day int, hour int, minute int, second int, ...)
- func ToCamelCase(input string) string
- func ToSnakeCase(raw string) string
- func TomlDecode(raw []byte, object any, algorithm string) error
- func TomlEncode(object any, compress bool, algorithm string) ([]byte, error)
- func TrafficbpsFormatKMGTPEZYBbps(trafficbps float64) (result float64, unit string)
- func TrimAllPrefixAndSuffixAsterisk(raw string) string
- func TrimAllPrefixAndSuffixBackSlash(raw string) string
- func TrimAllPrefixAndSuffixBackTick(raw string) string
- func TrimAllPrefixAndSuffixPoint(raw string) string
- func TrimAllPrefixAndSuffixSlash(raw string) string
- func TrimAllPrefixAndSuffixSpace(raw string) string
- func TrimAllPrefixAndSuffixSymbol(raw string, symbol string) string
- func TrimAllPrefixAsterisk(raw string) string
- func TrimAllPrefixBackSlash(raw string) string
- func TrimAllPrefixBackTick(raw string) string
- func TrimAllPrefixPoint(raw string) string
- func TrimAllPrefixSlash(raw string) string
- func TrimAllPrefixSpace(raw string) string
- func TrimAllPrefixSymbol(raw string, symbol string) string
- func TrimAllSpace(raw string) string
- func TrimAllSuffixAsterisk(raw string) string
- func TrimAllSuffixBackSlash(raw string) string
- func TrimAllSuffixBackTick(raw string) string
- func TrimAllSuffixPoint(raw string) string
- func TrimAllSuffixSlash(raw string) string
- func TrimAllSuffixSpace(raw string) string
- func TrimAllSuffixSymbol(raw string, symbol string) string
- func UintToIP(n uint32) net.IP
- func UnCompress(data []byte, algorithm string) ([]byte, error)
- func UnCompressWithFlate(raw []byte) ([]byte, error)
- func UnCompressWithGzip(raw []byte) ([]byte, error)
- func UnCompressWithLzw(raw []byte) ([]byte, error)
- func UnCompressWithZlib(raw []byte) ([]byte, error)
- func UnitFormat(size uint64) string
- func Validate(object any, language string) error
- func ValidateNil(object any) bool
- func XmlDecode(raw []byte, object any, algorithm string) error
- func XmlEncode(object any, namespace string, root string, compress bool, algorithm string) ([]byte, error)
- func YamlDecode(raw []byte, object any, algorithm string) error
- func YamlEncode(object any, compress bool, algorithm string) ([]byte, error)
- type Duration
- type NetworkInterfaceInfo
- type ScanResult
- func CheckIPPortReachable(ip net.IP, port uint, timeout time.Duration) (result ScanResult, err error)
- func CheckIPReachable(ip net.IP, ports []uint, timeout time.Duration) (result []ScanResult)
- func PingIP(ip net.IP, timeout time.Duration) ScanResult
- func ScanNetworkInterface(ifaceInfo NetworkInterfaceInfo, ports []uint, timeout time.Duration) []ScanResult
- type XSDuration
Constants ¶
This section is empty.
Variables ¶
var ( IPv4Regexp = regexp.MustCompile(ipv4RegexParten) IPv6Regexp = regexp.MustCompile(ipv6RegexParten) )
var ( // 匹配空格 RegexpSpace = regexp.MustCompile(`\s`) // 匹配以空格开头 RegexpPrefixSpace = regexp.MustCompile(`^\s`) // 匹配以空格结尾 RegexpSuffixSpace = regexp.MustCompile(`\s$`) // 匹配以空格开头或结尾 RegexpPrefixAndSuffixSpace = regexp.MustCompile(`^\s|\s$`) // 匹配以[.]开头 RegexpPrefixPoint = regexp.MustCompile(`^\.`) // 匹配以[.]结尾 RegexpSuffixPoint = regexp.MustCompile(`\.$`) // 匹配以[.]开头或结尾 RegexpPrefixAndSuffixPoint = regexp.MustCompile(`^\.|\\.$`) // 匹配以[/]开头 RegexpPrefixSlash = regexp.MustCompile(`^\/`) // 匹配以[/]结尾 RegexpSuffixSlash = regexp.MustCompile(`\/$`) // 匹配以[/]开头或结尾 RegexpPrefixAndSuffixSlash = regexp.MustCompile(`^\/|\/$`) // 匹配以[\]开头 RegexpPrefixBackSlash = regexp.MustCompile(`^\\`) // 匹配以[\]结尾 RegexpSuffixBackSlash = regexp.MustCompile(`\\$`) // 匹配以[\]开头或结尾 RegexpPrefixAndSuffixBackSlash = regexp.MustCompile(`^\\|\\$`) // 匹配以[`]开头 RegexpPrefixBackTick = regexp.MustCompile(`^` + "`") // 匹配以[`]结尾 RegexpSuffixBackTick = regexp.MustCompile("`$") // 匹配以[`]开头或结尾 RegexpPrefixAndSuffixBackTick = regexp.MustCompile(`^` + "`" + `|` + "`" + `$`) // 匹配以[*]开头 RegexpPrefixAsterisk = regexp.MustCompile(`^\*`) // 匹配以[*]结尾 RegexpSuffixAsterisk = regexp.MustCompile(`\*$`) // 匹配以[*]开头或结尾 RegexpPrefixAndSuffixAsterisk = regexp.MustCompile(`(^\*|\*$)`) // 匹配协议 RegexpSchema = regexp.MustCompile(`(?i)^(http|https|rpc|grpc|ws|wss|snmp|sip)\:\/\/`) // 匹配字母、数字的正则表达��� LetterDigitRegexp = regexp.MustCompile(`^[a-zA-Z0-9]+$`) // 匹配非字母、数字的正则表达式 NonLetterDigitRegexp = regexp.MustCompile(`[^a-zA-Z0-9]`) )
var ( // 常见端口 CommonPorts = []uint{80, 8080, 5000, 443, 554, 8554, 22, 5060, 3389} )
var TimeFormatSet = map[string]string{ time.Layout: time.Layout, time.ANSIC: time.ANSIC, time.UnixDate: time.UnixDate, time.RubyDate: time.RubyDate, time.RFC822: time.RFC822, time.RFC822Z: time.RFC822Z, time.RFC850: time.RFC850, time.RFC1123: time.RFC1123, time.RFC1123Z: time.RFC1123Z, time.RFC3339: time.RFC3339, time.RFC3339Nano: time.RFC3339Nano, time.Kitchen: time.Kitchen, time.Stamp: time.Stamp, time.StampMilli: time.StampMilli, time.StampMicro: time.StampMicro, time.StampNano: time.StampNano, time.DateTime: time.DateTime, time.DateOnly: time.DateOnly, time.TimeOnly: time.TimeOnly, }
时间格式集合
Functions ¶
func AutoParseTimeFromString ¶
自动解析时间格式
func BytesFromat ¶
字��(GB)单位转换: bit(位)、Byte(字节)、KB(千字节)、MB(兆字节)、GB(吉字节,千兆)、TB(万亿字节,太字节)、PB(千万亿字节,拍字节)、EB(百亿亿字节,艾字节)、ZB(十万亿亿字节,泽字节)、YB(一亿亿亿字节,尧字节)、BB(千亿亿亿字节) 1BB=1024YB=1024^2ZB=1024^3EB=1024^4PB=1024^5TB=1024^6GB=1024^7MB=1024^8KB=1024^9Byte=8*1024^9bit 1YB=1024ZB=1024^2EB=1024^3PB=1024^4TB=1024^5GB=1024^6MB=1024^7KB=1024^8Byte=8*1024^8bit 1ZB=1024EB=1024^2PB=1024^3TB=1024^4GB=1024^5MB=1024^6KB=1024^7Byte=8*1024^7bit 1EB=1024PB=1024^2TB=1024^3GB=1024^4MB=1024^5KB=1024^6Byte=8*1024^6bit 1PB=1024TB=1024^2GB=1024^3MB=1024^4KB=1024^5Byte=8*1024^5bit 1TB=1024GB=1024^2MB=1024^3KB=1024^4Byte=8*1024^4bit 1GB=1024MB=1024^2KB=1024^3Byte=8*1024^3bit 1MB=1024KB=1024^2Byte=8*1024^2bit 1KB=1024Byte=8*1024bit 1Byte=8bit
func CheckWritePermission ¶
CheckWritePermission 检查指定目录是否具有写入权限
func ComparePaths ¶
ComparePaths 比较两个路径是否相等,兼容不同操作系统
func CreateFileIFNotExist ¶
如果文件不存在就创建文件及文件所在目录,并返回文件绝对路径
func DSNIsMemory ¶
*
- @description: 判断 数据来源名称(Data Source Name) 是否是内存
- @param [string] dsn 数据来源名称(Data Source Name)
- @return [bool] 布尔值
func DistinctStringSlice2String ¶
字符串切片去重,返回指定分隔符字符串
func DistinctStringSlice2StringSlice ¶
字符串切片去重,返回字符串切片
func ExecuteCommand ¶
通用命令执行和解析
func FileIsExist ¶
判断文件/目录是否存在,如果存在则返回文件的绝对路径
func FrequencyFormat ¶
主频(GHz)单位转换: Hz、KHz、MHz、GHz、THz 1THz=10^3GHz=10^6MHz=10^9KHz=10^12Hz 1GHz=10^3MHz=10^6KHZ=10^9Hz 1MHz=10^3KHz=10^6Hz 1KHz=10^3Hz
func GetAllIPsInSubnetExceptSelf ¶
GetAllIPsInSubnetExceptSelf 获取子网内除自身外的所有 IP 地址
func GetCurrentUTCMonthWorkDay ¶
func GetCurrentUTCMonthWorkDay() int32
*
- @description: 获取 UTC 当前日期是当月第几个工作日
func GetCurrentUTCQuarterWeek ¶
func GetCurrentUTCQuarterWeek() int32
*
- @description: 获取 UTC 当前季度第几个星期
func GetCurrentUTCYearWorkDay ¶
func GetCurrentUTCYearWorkDay() int32
*
- @description: 获取 UTC 当前日期是当年第几个工作日
func GetFileAbsolutePath ¶
*
- @description: 获取文件/目录的绝对路径
- @param [string] file 源文件
- @return [string] 文件/目录的绝对路径
- @return [error] 错误信息
func GetFileRelativeWithoutParentFlagPath ¶
获取文件的相对无上级标记(../)路径
func GetInterfaceByIP ¶
GetInterfaceByIP 根据 局域网 IP 获取对应的网卡
func GetInterfaceIPs ¶
获取接口的指定协议地址列表
func GetLANIPByDNS ¶
GetLANIPByDNS 通过发送 DNS 服务请求获取 局域网(LAN) IP 利用 net.DialUDP 函数建立一个 UDP 连接到 8.8.8.8 的 53 端口(DNS 服务端口)
func GetLinuxARPTable ¶
GetLinuxARPTable Linux 处理逻辑
func GetMACFromIP ¶
GetMACFromIP 根据 IP 地址从系统 ARP 缓存中获取 MAC 地址(带验证)
func GetMacByIP ¶
GetMacByIP 根据 IP 地址从系统 ARP 缓存中获取 MAC 地址(带验证)
func GetMacOSARPTable ¶
GetMacOSARPTable macOS 处理逻辑
func GetNowTime ¶
func GetNowTime() (now time.Time, year int32, month int32, day int32, secondTimestamp int64, millisecondTimestamp int64, nanosecondTimestamp int64)
*
- @description: 获取当前时间相关信息
- 当前时间(currentTime)
- 当前年份(year)
- 当前月��(month)
- 当前季度(quarter)
- 当前星期(week)
- 当前年份的第几周(yearWeek)
- 当前月的第几周(monthWeek)
- 当前季度的第几周(quarterWeek)
- 当前年份的第几天(yearDay)
- 当前月的第几天(monthDay)
- 当前季度的第几天(quarterDay)
- 当前星期的第几天(weekDay)
- 当前小时(Hour)
- 当前季度的小时(QuarterHour)
- 当前星期的小时(WeekHour)
- 当前日的小时(DayHour)
- 当前时间戳(秒、毫秒、纳秒)(SecondsTimestamp, MillisecondsTimestamp, NanosecondsTimestamp
func GetUpAndBroadcastAndMulticastAndRunningInterfaces ¶
GetUpAndBroadcastAndMulticastAndRunningInterfaces 获取所有启用(up),广播(broadcast),组播(multicast),正常运行(running)的网卡
func GetUpAndPointtopointAndMulticastAndRunningInterfaces ¶
GetUpAndPointtopointAndMulticastAndRunningInterfaces 获取所有启用(up),点对点(pointtopoint),组播(multicast),正常运行(running)的网卡
func GetUpAndRunningInterfaces ¶
GetUpAndRunningInterfaces 获取所有启用(up),正常运行(running)的网卡 net.FlagUp: 0 :表明网卡处于启用状态,要是这个标志被设置,就意味着网卡已经开启并且可以正常工作 net.FlagBroadcast: 1 :表示网卡支持广播功能,支持广播的网卡能够向网络中的所有设备发送数据包 net.FlagLoopback: 2 :意味着网卡是��环接口,回环接口主要用于本地测试,数据包不会被发送到物理网络,而是直接返回给本地系统 net.FlagPointToPoint: 3 :表示网卡是点对点接口,这种接口通常用于连接两个特定的设备,像 PPP 连接 net.FlagMulticast: 4 :表示网卡支持组播功能,支持组播的网卡能够向网络中的一组特定设备发送数据包 net.FlagRunning: 5 :这个标志表示网络接口处于运行状态,与 FlagUp 不同,FlagUp 侧重于管理层面的启用,而 FlagRunning 更强调网络接口在物理层面或者实际操作中正在正常工作
func GetWindowsARPTable ¶
GetWindowsARPTable Windows 处理逻辑
func IsURLEncodedByDecoding ¶
IsURLEncodedByDecoding 尝试解码并检查结果
func IsValidMAC ¶
IsValidMAC 检查 MAC 地址 是否有效 支持的格式: - 00:1A:2B:3C:4D:5E (冒号分隔) - 00-1A-2B-3C-4D-5E (连字符分隔) - 001A2B3C4D5E (无分隔符)
func IsValidStandMAC ¶
IsValidStandMAC 是否是标准有效的 MAC 校验
func JsonEncode ¶
json 格式序列化
object any : 序列化对象 escape bool : 是否进行转义 compress bool : 是否进行压缩 algorithm string : 压缩算法
func MDNSSearch ¶
func MicrosecondsStatistics ¶
func MicrosecondsStatistics(number int64) (years int32, months int32, days int32, hours int32, minutes int32, seconds int32, milliseconds int32, microseconds int32, nanoseconds int32)
微秒时长统计(统计经历时长/总计时长): 多少年,多少月,多少天,多少小时,多少分钟,多少秒,多少毫秒,多少微秒,多少纳秒
func MillisecondTimestampFormatDaysHoursMinutesSeconds ¶
func MillisecondTimestampFormatDaysHoursMinutesSeconds(timestamp float64) (days int32, hours int32, minutes int32, seconds float64)
毫秒时间戳格式化
func MillisecondsStatistics ¶
func MillisecondsStatistics(number int64) (years int32, months int32, days int32, hours int32, minutes int32, seconds int32, milliseconds int32, microseconds int32, nanoseconds int32)
毫秒时长统计(统计经历时长/总计时长): 多少年,多少月,多少天,多少小时,多少分钟,多少秒,多少毫秒,多少微秒,多少纳秒
func NanosecondsStatistics ¶
func NanosecondsStatistics(number int64) (years int32, months int32, days int32, hours int32, minutes int32, seconds int32, milliseconds int32, microseconds int32, nanoseconds int32)
纳秒时长统计(统计经历时长/总计时长): 多少年,多少月,多少天,多少小时,多少分钟,多少秒,多少毫秒,多少微秒,多少纳秒
func NormalizeMAC ¶
NormalizeMAC 将 MAC 地址标准化为冒号分隔格式 如 001A2B3C4D5E 转为 00:1A:2B:3C:4D:5E
func NormalizePath ¶
NormalizePath 规范化文件路径,适应不同操作系统的分隔符和大小写问题
func Number2Float32 ¶
数值类型转换成float32类型,precision: 精度/倍乘数/倍乘因子
func Number2Float64 ¶
数值类型转换成float64类型,precision: 精度/倍乘数/倍乘因子
func Number2Int16 ¶
数值类型转换成int16类型,precision: 精度/倍乘数/倍乘因子
func Number2Int32 ¶
数值类型转换成int32类型,precision: 精度/倍乘数/倍乘因子
func Number2Int64 ¶
数值类型转换成int64类型,precision: 精度/倍乘数/倍乘因子
func Number2Int8 ¶
数值类型转换成int8类型,precision: 精度/倍乘数/倍乘因子
func Number2Uint16 ¶
数值类型转换成uint16类型,precision: 精度/倍乘数/倍乘因子
func Number2Uint32 ¶
数值类型转换成uint32类型,precision: 精度/倍乘数/倍乘因子
func Number2Uint64 ¶
数值类型转换成uint64类型,precision: 精度/倍乘���/倍乘因子
func Number2Uint8 ¶
数值类型转换成uint8类型,precision: 精度/倍乘数/倍乘因子
func ParseARPCommandOutput ¶
解析 arp 命令输出
func ParseAddress ¶
func ParseProcNetARP ¶
解析/proc/net/arp文件
func ParseURLEncodedByDecoding ¶
ParseURLEncodedByDecoding 尝试解码
func RandomString ¶
RandomString 函数生成指定长度的随机字符串 length 是要生成的字符串的长度 返回生成的随机字符串
func RegexpTrimAllPrefixAndSuffixAsterisk ¶
正则去除字符串所有[*]前缀和[*]后缀
func RegexpTrimAllPrefixAndSuffixBackSlash ¶
正则去除字���串所有[\]前缀和[\]后缀
func RegexpTrimAllPrefixAndSuffixBackTick ¶
正则去除字符串所有[`]前缀和[`]后缀
func RegexpTrimAllPrefixAndSuffixPoint ¶
正则去除字符串所有[.]前缀和[.]后缀
func RegexpTrimAllPrefixAndSuffixSlash ¶
正则去除字符串所有[/]前缀和[/]后缀
func RegexpTrimAllPrefixAndSuffixSpace ¶
正则去除字符串所有空格前缀和空格后缀
func RegexpTrimAllPrefixAndSuffixSymbol ¶
正则指定去除字符串所有前缀和后缀
func RegexpTrimAllPrefixAsterisk ¶
正则去除字符串所有[*]前缀
func RegexpTrimAllPrefixBackSlash ¶
正则去除字符串所有[\]前缀
func RegexpTrimAllPrefixBackTick ¶
正则去除字符串所有[`]前缀
func RegexpTrimAllPrefixSymbol ¶
正则指定去除字符串所有前缀
func RegexpTrimAllSuffixAsterisk ¶
正则去除字符串所有[*]后缀
func RegexpTrimAllSuffixBackSlash ¶
正��去除字符串所有[\]后缀
func RegexpTrimAllSuffixBackTick ¶
正则去除字符串所有[`]后缀
func RegexpTrimAllSuffixSymbol ¶
正则指定去除字符串所有后缀
func RemoveStringSliceElement ¶
去除字符串切片中的元素
func SecondsStatistics ¶
func SecondsStatistics(number int64) (years int32, months int32, days int32, hours int32, minutes int32, seconds int32, milliseconds int32, microseconds int32, nanoseconds int32)
秒时长统计(统计经历时长/总计时长): 多少年,多少月,多少天,多少小时,多少分钟,多少秒,多少毫秒,多少微秒,多少纳秒
func TimestampParse ¶
func TimestampParse(timestamp int64) (year int, month int, day int, hour int, minute int, second int, millisecond int, microsecond int, nanosecond int)
时间戳解析: 年,月,日,时,分,秒,毫秒,微妙,纳秒
func TrafficbpsFormatKMGTPEZYBbps ¶
流量单位转换: bps(位/秒)、Kbps(千字节/秒)、Mbps(兆字节/秒)、Gbps(吉字节/秒,千兆/秒)、Tbps(万亿字节/秒,太字节/秒)、Pbps(千万亿字节/秒,拍字节/秒)、Ebps(百亿亿字节/秒,艾字节/秒)、Zbps(十万亿亿字节/秒,泽字节/秒)、Ybps(一亿亿亿字节/秒,尧字节/秒)、Bbps(千亿亿亿字节/秒) 1bps=1bps 1Kbps=1024bps 1Mbps=1024Kbps=1024^2=1024^2bps 1Gbps=1024Mbps=1024^2Kbps=1024^3bps=1024^3bps 1Tbps=1024Gbps=1024^2Mbps=1024^3Kbps=1024^4bps 1Pbps=1024Tbps=1024^2Gbps=1024^3Mbps=1024^4Kbps=1024^5bps 1Ebps=1024Pbps=1024^2Tbps=1024^3Gbps=1024^4Mbps=1024^5Kbps=1024^6bps 1Zbps=1024Ebps=1024^2Pbps=1024^3Tbps=1024^4Gbps=1024^5Mbps=1024^6Kbps=1024^7bps 1Ybps=1024Zbps=1024^2Ebps=1024^3Pbps=1024^4Tbps=1024^5Gbps=1024^6Mbps=1024^7Kbps=1024^8bps 1Bbps=1024Ybps=1024^2Zbps=1024^3Ebps=1024^4Pbps=1024^5Tbps=1024^6Gbps=1024^7Mbps=1024^8Kbps=1024^9bps
func TrimAllPrefixAndSuffixAsterisk ¶
去除字符串所有[*]前缀和[*]后缀
func TrimAllPrefixAndSuffixBackSlash ¶
去除字符串所有[\]前缀和[\]后缀
func TrimAllPrefixAndSuffixBackTick ¶
去除字符串所有[`]前缀和[`]后缀
func TrimAllPrefixAndSuffixPoint ¶
去除字符串所有[.]前缀和[.]后缀
func TrimAllPrefixAndSuffixSlash ¶
去除字符串所有[/]前缀和[/]后缀
func TrimAllPrefixAndSuffixSpace ¶
去除字符串所有空格前缀和空格后缀
func TrimAllPrefixAndSuffixSymbol ¶
指定去除字符串所有前缀和后缀
func UnCompressWithLzw ¶
Lempel-Ziv-Welch (LZW) 解压
func ValidateNil ¶
func XmlEncode ¶
func XmlEncode(object any, namespace string, root string, compress bool, algorithm string) ([]byte, error)
序列化 xml 格式序列化
object any : 序列化对象 namespace string : 命名空间 root string : 根节点名称 compress bool : 是否进行压缩 algorithm string : 压缩算法
Types ¶
type Duration ¶
type Duration struct {
// contains filtered or unexported fields
}
Duration of iso8601
func NewDuration ¶
NewDuration return duration
func (Duration) ISO8601Duration ¶
ISO8601Duration to string
type NetworkInterfaceInfo ¶
type NetworkInterfaceInfo struct {
Name string
HardwareAddr string
IPNetworks []*net.IPNet
Iface *net.Interface
}
NetworkInterfaceInfo 存储网络接口信息
func GetAvailableNetworkInterfaces ¶
func GetAvailableNetworkInterfaces(includeIPv6 bool) ([]NetworkInterfaceInfo, error)
GetAvailableNetworkInterfaces 获取所有可用网络接口信息: 跳过回环接口和未启用的接口
type ScanResult ¶
type ScanResult struct {
IP net.IP
Port uint
Address string
Mac string
Reachable bool
Latency time.Duration
}
ScanResult 存储扫描结果
func CheckIPPortReachable ¶
func CheckIPPortReachable(ip net.IP, port uint, timeout time.Duration) (result ScanResult, err error)
CheckIPPortReachable 检查 IP:port 是否可达
func CheckIPReachable ¶
CheckIPReachable 检查 IP 是否可达
func PingIP ¶
func PingIP(ip net.IP, timeout time.Duration) ScanResult
PingIP 使用 ICMP 进行更准确的连通性检测(需要权限)
func ScanNetworkInterface ¶
func ScanNetworkInterface(ifaceInfo NetworkInterfaceInfo, ports []uint, timeout time.Duration) []ScanResult
ScanNetworkInterface 扫描网络接口的子网 IP
type XSDuration ¶
type XSDuration struct {
Negative bool
Years int
Months int
Days int
Hours int
Minutes int
Seconds float64
}
XSDuration 表示 xs:duration 类型
func ParseXSDuration ¶
func ParseXSDuration(durationStr string) (XSDuration, error)
ParseXSDuration 解析 xs:duration 字符串
func (XSDuration) ToDuration ¶
func (d XSDuration) ToDuration() time.Duration
ToDuration 将 XSDuration 转换为 time.Duration 注意:此方法会忽略年和月,因为它们无法精确转换为固定的时间长度