commonutil

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes2Hexstring

func Bytes2Hexstring(bs []byte, upper bool) string

字节切片转为16进制表示字符串 区别与%x,不忽略前面的0,全部打印

func Bytes2Ip

func Bytes2Ip(bs []byte) net.IP

[]byte-->ip地址

func Bytes2Ipstring

func Bytes2Ipstring(bs []byte) string

[]byte-->ipstring

func Bytes2String

func Bytes2String(bs []byte) string

Bytes 转 字符串

func Bytes2Timestr

func Bytes2Timestr(bs []byte, fmt string) string

4字节表示秒转时间字符串

func Bytes2Uint16

func Bytes2Uint16(bs []byte) uint16

region 数值转换

byte数组转uint16 - 大端

func Bytes2Uint32

func Bytes2Uint32(bs []byte) uint32

byte数组转uint32 - 大端

func Bytes2Uint64

func Bytes2Uint64(bs []byte) uint64

byte数组转uint64 - 大端

func CompareNoCaseString

func CompareNoCaseString(s1 string, s2 string) int

func FlipBytes

func FlipBytes(bs []byte) []byte

翻转给定一个byte数组

func Hexstring2Bytes

func Hexstring2Bytes(hexstring string) []byte

region 16进制字符串转换

16进制的字符串转换为字节切片 区别标准库,自动忽略字符串中的0-9 a-f A-F之外的其他字符 " 1t2y2u\r\n3a4b"也可以

func Ip2Bytes

func Ip2Bytes(ip net.IP) []byte

ip地址->[]byte

func Ip2Ipstring

func Ip2Ipstring(ip net.IP) string

region 地址转换 ip地址->ipstring

func IpEqual

func IpEqual(ip1 net.IP, ip2 net.IP) bool

func IpVersion

func IpVersion(ip net.IP) int

获取ip地址版本4/6

func Ipstring2Bytes

func Ipstring2Bytes(ipstr string) []byte

ipstring-->[]byte

func Ipstring2Ip

func Ipstring2Ip(ipstr string) net.IP

ipstring-->ip地址

func IpstringEqual

func IpstringEqual(ip1 string, ip2 string) bool

ip地址是否相等

func Nanosecond2Time

func Nanosecond2Time(nanosecond int64) time.Time

纳秒转time.Time

func Second2Time

func Second2Time(second int64) time.Time

从秒转time.Time

func Second2Timestr

func Second2Timestr(second int64, fmt string) string

秒转时间字符串

func String2Bytes

func String2Bytes(str string) []byte

region string bytes转换 字符串 转 bytes

func StringDelSpace

func StringDelSpace(str string) string

删除字符串中所有的空白字符 包含空格,tab,回车,换行

func StringTrim

func StringTrim(str string) string

删除字符串前后的空白字符 包含空格,tab,回车,换行

func StringTrimLeft

func StringTrimLeft(str string) string

region 字符串截断

删除字符串前面的空白字符 包含空格,tab,回车,换行

func StringTrimRight

func StringTrimRight(str string) string

删除字符串后面的空白字符 包含空格,tab,回车,换行

func Time2Nanosecond

func Time2Nanosecond(t time.Time) int64

time.Time转纳秒

func Time2Second

func Time2Second(t time.Time) int64

time.Time转秒 从1970-01-01 00:00:00开始

func Time2Timestr

func Time2Timestr(t time.Time, fmt string) string

region 时间转换 time 转时间字符串 * 常用时间格式化字符串 2006-01-02 15:03:04 2022-02-22 20:07:16

2006-01-02 15:03:04.999999 2022-02-22 20:07:16.6654375 2006-01-02 15:04:05.999999 Z0700 MST 2022-02-22 20:07:16.6654375 +0800 CST

func Timestr2Bytes

func Timestr2Bytes(timestr string, fmt string) [4]byte

时间字符串转4字节表示秒

func Timestr2Second

func Timestr2Second(timestr string, fmt string) int

时间字符串转秒

func Timestr2Time

func Timestr2Time(timestr string, fmt string) time.Time

时间字符串转时间 timestr 本地时间.如果失败,返回1970年开始时间,时间值=0

func Uint162Bytes

func Uint162Bytes(x uint16) [2]byte

uint16转byte数组 - 大端

func Uint322Bytes

func Uint322Bytes(x uint32) [4]byte

uint32转byte数组 - 大端

func Uint642Bytes

func Uint642Bytes(x uint64) [8]byte

uint64转byte数组 - 大端

func UnwrapIp

func UnwrapIp(ipstr string) string

unwrap ip地址,如果字符串以[]包裹,去除[]

func WrapIp

func WrapIp(ipstr string) string

wrap ip地址,如果地址是一个IPv6地址,那么添加[]

Types

type ResultInfo

type ResultInfo struct {
	Ret     string
	RetMsg  string
	RetData interface{}
}

Jump to

Keyboard shortcuts

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