system

package module
v0.0.0-...-f451f3d Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: MIT Imports: 20 Imported by: 3

README

system

The system package for GoLang.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cron *cron.Cron
View Source
var Env = new(env)
View Source
var Hardware = new(HardwareInfo)
View Source
var IpAddr = new(ipAddr)
View Source
var Quartz = new(quartz)
View Source
var Terminal = new(terminal)
View Source
var Version = "0.0.1"

Version Set by release.

Functions

func CallBrowser

func CallBrowser(uri string) error

Calls the OS default browser for open uri

func CurrentAndAbsPath

func CurrentAndAbsPath() string

当前执行程序的绝对路径

func GetAbsPath

func GetAbsPath(current string) string

获取当前执行程序的绝对路径

func GetConfigDir

func GetConfigDir() string

获取配置目录

func GetCurrentDir

func GetCurrentDir() string

获取当前执行程序的绝对目录路径

func GetCurrentFilename

func GetCurrentFilename() string

当前执行程序的绝对文件路径

func GetDirPath

func GetDirPath(dirname string) string

Get absolute path by directory name.

func GetFilepath

func GetFilepath(dirname string, filename string) string

Get absolute path by directory name and file name.

func GetLastPath

func GetLastPath(currentPath string) string

获取路径的上个目录

func GetOS

func GetOS() string

Get OS types.

func GetRootPath

func GetRootPath() string

获取项目根目录

func ParseEnvVar

func ParseEnvVar(varString string) string

环境变量解析: 根据环境变量的值替换字符串中的 ${var} or $var, 如果不存在任何环境变量, 则使用空字符串替换

func SetCurrentPath

func SetCurrentPath() string

设置当前执行程序的相对路径

Types

type CommandServices

type CommandServices struct {
	ExecDir  string
	ExecName string
	PidDir   string
	PidName  string
}

func (*CommandServices) Run

func (cs *CommandServices) Run(execDir, execName, pidDir, pidName string)

type DaemonServices

type DaemonServices struct {
	ExecDir  string
	ExecName string
	PidDir   string
	PidName  string
	// contains filtered or unexported fields
}

func (*DaemonServices) GetPidPath

func (d *DaemonServices) GetPidPath() string

func (*DaemonServices) GetProgramPath

func (d *DaemonServices) GetProgramPath() string

func (*DaemonServices) New

func (d *DaemonServices) New(execDir, execName, pidDir, pidName string) *DaemonServices

func (*DaemonServices) Restart

func (d *DaemonServices) Restart() bool

func (*DaemonServices) Start

func (d *DaemonServices) Start() bool

func (*DaemonServices) Stop

func (d *DaemonServices) Stop() bool

func (*DaemonServices) Usage

func (d *DaemonServices) Usage()

type HardwareInfo

type HardwareInfo struct {
	CPU             float64 `json:"cpu"`
	DiskFree        uint64  `json:"diskFree"`
	DiskUsedPercent float64 `json:"diskUsedPercent"`
	MemUsedPercent  float64 `json:"memUsedPercent"`
	GoMemory        int64   `json:"goMemory"`
	GoRoutines      int     `json:"goRoutines"`
	DirPath         string
}

func (*HardwareInfo) CountGoUseRam

func (info *HardwareInfo) CountGoUseRam() int64

计算Golang运行时分配的内存总字节数

func (*HardwareInfo) CountGoroutine

func (info *HardwareInfo) CountGoroutine() int

计算当前Goroutine的数量

func (*HardwareInfo) CpuInfo

func (info *HardwareInfo) CpuInfo() []cpu.InfoStat

获取CPU信息

func (*HardwareInfo) CpuLoad

func (info *HardwareInfo) CpuLoad() *load.AvgStat

获取CPU平均负载

func (*HardwareInfo) DiskFreeSpace

func (info *HardwareInfo) DiskFreeSpace() (diskFree uint64)

获取硬盘已使用空间

func (*HardwareInfo) DiskState

func (info *HardwareInfo) DiskState() (diskFree uint64, diskUsed float64)

获取硬盘状态

func (*HardwareInfo) GetCpuPercent

func (info *HardwareInfo) GetCpuPercent() (cpuInfo float64)

func (*HardwareInfo) GetDiskUsedPercent

func (info *HardwareInfo) GetDiskUsedPercent() (diskUsed float64)

获取硬盘使用百分比

func (*HardwareInfo) GetHardwareState

func (info *HardwareInfo) GetHardwareState()

获取系统运行时的硬件状态

func (*HardwareInfo) IsDiskFull

func (info *HardwareInfo) IsDiskFull(dir string) bool

检查磁盘空间是否已满

func (*HardwareInfo) RamUsed

func (info *HardwareInfo) RamUsed() (used float64)

获取内存使用率

Jump to

Keyboard shortcuts

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