base

package
v0.0.0-...-5f1ca4c Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CatchError

func CatchError(handle func(e interface{}))

CatchError 捕捉异常

func GetCpuInfo

func GetCpuInfo()

func GetGoRoutineId

func GetGoRoutineId() uint64

获取goroutine id *

  • runtime.stack-> goroutine 4 [running]:
  • gitee.com/liueric/generic/base.GetGoRouti
  • runtime.TrimPrefix-> 4 [running]:
  • gitee.com/liueric/generic/base.GetGoRouti
  • 4 *

func GetIps

func GetIps() ([]string, []string, error)

GetIps 获取ip 集合

func IPToInt64

func IPToInt64(ip string) int64

IPToInt64 ip 转字数字

func Int64ToIP

func Int64ToIP(ip int64) string

Int64ToIP 还原ip

func PrintStackTrace

func PrintStackTrace(err interface{}) string

PrintStackTrace 组织堆栈信息

Types

type ByteUnit

type ByteUnit struct {
	// contains filtered or unexported fields
}
var (
	BYTE *ByteUnit = newByteUnit(BYTE_, 1)
	KiB  *ByteUnit = newByteUnit(KiB_, 1<<10)
	MiB  *ByteUnit = newByteUnit(MiB_, 1<<20)
	GiB  *ByteUnit = newByteUnit(GiB_, 1<<30)
	TiB  *ByteUnit = newByteUnit(TiB_, 1<<40)
	PiB  *ByteUnit = newByteUnit(PiB_, 1<<50)
)

func (*ByteUnit) ConvertByBytes

func (bu *ByteUnit) ConvertByBytes(v int64, fu ByteUnit) (res int64, err error)

func (*ByteUnit) ToBytes

func (bu *ByteUnit) ToBytes(v int64) (res int64, err error)

func (*ByteUnit) ToGiB

func (bu *ByteUnit) ToGiB(v int64) (res int64, err error)

func (*ByteUnit) ToKiB

func (bu *ByteUnit) ToKiB(v int64) (res int64, err error)

func (*ByteUnit) ToMiB

func (bu *ByteUnit) ToMiB(v int64) (res int64, err error)

func (*ByteUnit) ToPiB

func (bu *ByteUnit) ToPiB(v int64) (res int64, err error)

func (*ByteUnit) ToTiB

func (bu *ByteUnit) ToTiB(v int64) (res int64, err error)

type ByteUnitType

type ByteUnitType string

* Power Exact Value Approx Value Bytes --------------------------------------------------------------- 7 128 8 256 10 1024 1 thousand 1 KB 16 65,536 64 KB 20 1,048,576 1 million 1 MB 30 1,073,741,824 1 billion 1 GB 32 4,294,967,296 4 GB 40 1,099,511,627,776 1 trillion 1 TB

const (
	BYTE_ ByteUnitType = "byte"
	KiB_  ByteUnitType = "KiB"
	MiB_  ByteUnitType = "MiB"
	GiB_  ByteUnitType = "GiB"
	TiB_  ByteUnitType = "TiB"
	PiB_  ByteUnitType = "PiB"
)

type ClientAddr

type ClientAddr struct {
	Ip   string `json:ip`
	Ipv6 string `json:ipv6`
	Mac  string `json:mac`
	Mask string `json:mask`
}

func GetLocalAddr

func GetLocalAddr() ([]*ClientAddr, error)

GetLocalAddr 获取本地mac ip地址

type ClientStatus

type ClientStatus struct {
	Cpu      []float64 `json:cpu`  // CPU百分比(%)
	Host     string    `json:host` // 主机名称
	Ip       []string  `json:ip`   // IP地址信息(可能多个)
	Ipv6     []string  `json:ipv6` // IP地址信息(可能多个)
	Mac      string    `json:mac`
	MemUsed  uint64    `json:mem_used`  // 内存使用(byte)
	MemTotal uint64    `json:mem_total` // 内存总量(byte)
	Time     int       `json:time`      // 上报时间(时间戳)
}

func GetClientInfo

func GetClientInfo() *ClientStatus

GetClientInfo 获取客户端信息

Jump to

Keyboard shortcuts

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