system

package
v1.3.59 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: Zlib Imports: 18 Imported by: 3

Documentation

Index

Constants

View Source
const (
	IptUnk  = IPType(0)
	IptPub  = IPType(1)
	IptPriA = IPType(2)
	IptPriB = IPType(3)
	IptPriC = IPType(4)
)
View Source
const GB = 1024 * 1024 * 1024
View Source
const (
	KLocalHost = "127.0.0.1"
)

Variables

View Source
var (
	ResolveIp = net.IP{}
	PublicIp  = net.IP{}
)

Functions

func AsyExec added in v1.1.11

func AsyExec(cmd string) <-chan CmdResult

AsyExec 异步执行,返回chan

func CmdStart added in v1.0.58

func CmdStart(cmd *exec.Cmd, conf *Config, env ...string) (*exec.Cmd, error)

func CreateTmpShellFile added in v1.1.11

func CreateTmpShellFile(pattern, content string) (tmpFile string, err error)

CreateTmpShellFile 创建临时的 shell 脚本文件 content 创建的脚本内容

func GetPublicIP added in v0.5.39

func GetPublicIP() (net.IP, error)

func GetPublicIPWithUrl added in v1.1.3

func GetPublicIPWithUrl(url string) (net.IP, error)

func GetResolveIP added in v0.5.39

func GetResolveIP() (net.IP, error)

func GetResolveIPV2 added in v0.5.39

func GetResolveIPV2() (net.IP, error)

func IPIsSelf added in v1.1.3

func IPIsSelf(ip string) string

IPIsSelf 是否是自己

func Info

func Info() string

func IsLanIP added in v1.1.3

func IsLanIP(IP net.IP) bool

IsLanIP 是否局域网 192.168.x.x

func IsPublicIP

func IsPublicIP(IP net.IP) bool

func Main added in v1.2.1

func Main() *mainRun

func PublicIPValid added in v0.7.0

func PublicIPValid() bool

func Quit

func Quit()

func Run added in v0.2.3

func Run()

func SelfExternalIP added in v1.1.3

func SelfExternalIP(lan bool) string

SelfExternalIP 自己外部IP,可能是局域网IP,公网IP lan 局域网优先

func ShellStart added in v1.1.19

func ShellStart(args []string, config Config, env ...string) (*exec.Cmd, error)

func StripArgs added in v1.0.58

func StripArgs(args []string, arg string) []string

Types

type Chan

type Chan struct {
	S chan os.Signal
}

func Exit added in v0.2.7

func Exit() *Chan

func (*Chan) Done added in v1.1.18

func (c *Chan) Done() <-chan os.Signal

type CmdResult added in v1.1.19

type CmdResult struct {
	Command   string
	Err       error
	StartTime time.Time
	EndTime   time.Time
	// contains filtered or unexported fields
}

func CmdRun added in v1.0.58

func CmdRun(cmd string, timeout time.Duration) CmdResult

CmdRun 超时同步执行, 等待结果返回 Deprecated: this function simply calls SyncExec.

func ShellRun added in v1.0.58

func ShellRun(cmd string) CmdResult

ShellRun 阻塞式同步执行

func SyncExec added in v1.1.11

func SyncExec(cmd string, timeout time.Duration) CmdResult

SyncExec 超时同步执行 timeout = 0, default 30 seconds

func (CmdResult) Error added in v1.1.19

func (r CmdResult) Error() string

func (CmdResult) Result added in v1.1.19

func (r CmdResult) Result() string

type Config added in v1.0.58

type Config struct {
	Stdin     io.Reader
	Stdout    io.Writer
	Stderr    io.Writer
	EnableStd bool `json:"enableStd" yaml:"enableStd" xml:"enableStd"`
	EnableEnv bool `json:"enableEnv" yaml:"enableEnv" xml:"enableEnv"`
}

type CpuInfo added in v1.0.16

type CpuInfo struct {
	User   float64 `json:"user"`
	System float64 `json:"system"`
	Idle   float64 `json:"idle"`
	Nice   float64 `json:"nice"`
}

func Cpu added in v1.0.0

func Cpu() CpuInfo

type DiskPath added in v1.0.16

type DiskPath struct {
	Path        string  `json:"path,omitempty"`
	Total       uint64  `json:"total"`
	Free        uint64  `json:"free"`
	Used        uint64  `json:"used"`
	UsedPercent float64 `json:"usedPercent"`
}

func Disk added in v1.0.0

func Disk() DiskPath

type Event

type Event struct {
	// contains filtered or unexported fields
}

Event represents a one-time event that may occur in the future.

func NewEvent

func NewEvent() *Event

NewEvent returns a new, ready-to-use Event.

func (*Event) Done

func (e *Event) Done() <-chan struct{}

Done returns a channel that will be closed when Fire is called.

func (*Event) Fire

func (e *Event) Fire() bool

Fire causes e to complete. It is safe to call multiple times, and concurrently. It returns true iff this call to Fire caused the signaling channel returned by Done to close.

func (*Event) HasFired

func (e *Event) HasFired() bool

HasFired returns true if Fire has been called.

type IPType

type IPType int8

func GetIPType

func GetIPType(IP net.IP) IPType

type MemInfo added in v1.0.0

type MemInfo struct {
	// Total amount of RAM on this system
	Total uint64 `json:"total"`

	// RAM available for programs to allocate
	//
	// This value is computed from the kernel specific values.
	Available uint64 `json:"available"`

	// RAM used by programs
	//
	// This value is computed from the kernel specific values.
	Used uint64 `json:"used"`

	// Percentage of RAM used by programs
	//
	// This value is computed from the kernel specific values.
	UsedPercent float64 `json:"usedPercent"`
}

func Mem added in v1.0.0

func Mem() MemInfo

Jump to

Keyboard shortcuts

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