Documentation ¶
Overview ¶
Package runtimeKit 主要是对如下包的封装:"runtime"
Index ¶
- Variables
- func GetAvailableMemoryPercent() (float64, error)
- func GetAvailableMemoryRatio() (float64, error)
- func GetDockerIdList() ([]string, error)
- func GetMacAddresses() ([]string, error)
- func GetUsedMemoryPercent() (float64, error)
- func GetUsedMemoryRatio() (float64, error)
- func PidExists(pid int32) (bool, error)
- func SetSoftMemoryLimit(limit int64) (int64, error)
- type MemoryStat
Constants ¶
This section is empty.
Variables ¶
var GoRoot string
GoRoot GOROOT环境变量
var GoVersion string
GoVersion Golang的版本号
var PID int = os.Getpid()
PID 当前进程的id.
Functions ¶
func GetAvailableMemoryRatio ¶
GetAvailableMemoryRatio 获取可用内存的比例
@return e.g. (0.4909677505493164, nil)
“比例”和“比率”的区别? 全班人数50人,男生30,女生20,那男生的比例就是30/50,同理女生的就是20/50,那么男女的比率是什么呢,是30/20。
func GetMacAddresses ¶
GetMacAddresses *
- 参考:https://blog.csdn.net/chixielao6059/article/details/100860506 *
- MAC地址:主机网卡的物理地址.
func PidExists ¶
PidExists 判断 传参pid 对应的进程是否存在
PS: 通过 第三方库gopsutil 实现.
e.g. (-1) => (false, error(invalid pid -1)) (13120) => (true, nil) (13121) => (false, nil)
func SetSoftMemoryLimit ¶
SetSoftMemoryLimit 软内存限制(soft memory limit)
PS: (1) This limit will be respected even if GOGC=off (or, if SetGCPercent(-1) is executed). (2) 默认memory limit是math.MaxInt64(即第一次调用debug.SetMemoryLimit()的返回值为math.MaxInt64).
@param limit 单位: B(byte;字节) @return 之前的内存限制
Types ¶
type MemoryStat ¶
type MemoryStat mem.VirtualMemoryStat
MemoryStat Total = Available + Used
func (MemoryStat) GetAvailablePercent ¶
func (stat MemoryStat) GetAvailablePercent() float64
GetAvailablePercent
e.g. 51.035356521606445
func (MemoryStat) String ¶
func (stat MemoryStat) String() string