Documentation ¶
Index ¶
- Constants
- Variables
- func ExecCmd(name string, params ...string) (string, string, error)
- func FreeOS()
- func GetCPUNum() int
- func GetCgroupMemoryLimit() (uint64, error)
- func GetCgroupProcessMemoryPercent() (float64, error)
- func GetExePath() (exePath string, err error)
- func GetFirstGopath(allowAutomaticGuessing bool) (gopath string, err error)
- func GetGoPath() []string
- func GetGoroutineNum() int
- func GetHostname() string
- func GetMemoryStat() (total, used, free uint64, usedPercent float64)
- func GetProcessCPUStat() (float64, error)
- func GetProcessMemoryPercent() (float32, error)
- func GetProcessMemoryStat() (uint64, error)
- func GetRoutineId() uint64
- func GetThreadNum() int
- func GetWorkDir() string
- func Gid() (id int64)
- func GoRoutine(function func())
- func GoRoutineInLoop(function func())
- func GoRoutineInTimer(duration time.Duration, function func())
- func GoSafely(wg *sync.WaitGroup, ignoreRecover bool, handler func(), ...)
- func GoUnterminated(handle func(), wg *sync.WaitGroup, ignoreRecover bool, period time.Duration)
- func GoVarLoop(n uint64, function func())
- func InitFreeOS()
- func IsCgroup() bool
- func IsLittleEndian() bool
- func OSIsUnix(os string) bool
- func RegisterSignalForPrintStack(sig os.Signal, callback func([]byte))
- func RegisterSignalForProfiling(sig ...os.Signal)
- func Reload() error
- func SwapEndianUin32(val uint32) uint32
- type OSMemStats
- type Result
Constants ¶
const ( OSWindows = "windows" OSDarwin = "darwin" OSDragonfly = "dragonfly" OSFreebsd = "freebsd" OSLinux = "linux" OSNacl = "nacl" OSNetbsd = "netbsd" OSOpenbsd = "openbsd" OSSolaris = "solaris" )
These are the names of the operating systems recognized by Go.
Variables ¶
var CurrentPID = os.Getpid()
CurrentPID returns the process id of the caller.
var OSUnix = []string{ OSDarwin, OSDragonfly, OSFreebsd, OSLinux, OSNacl, OSNetbsd, OSOpenbsd, OSSolaris, }
OSUnix is the list of unix-like operating systems recognized by Go. See http://golang.org/src/path/filepath/path_unix.go.
Functions ¶
func GetCgroupMemoryLimit ¶ added in v0.0.6
GetCgroupMemoryLimit returns a container's total memory in bytes
func GetCgroupProcessMemoryPercent ¶ added in v0.0.6
GetCgroupProcessMemoryPercent gets current process's memory usage percent in cgroup env
func GetExePath ¶ added in v0.0.5
func GetFirstGopath ¶ added in v0.0.9
GetFirstGopath gets the first $GOPATH value.
func GetGoPath ¶ added in v0.0.9
func GetGoPath() []string
GetGopaths returns the list of Go path directories.
func GetGoroutineNum ¶ added in v0.0.6
func GetGoroutineNum() int
GetGoroutineNum gets current process's goroutine number
func GetMemoryStat ¶ added in v0.0.6
func GetProcessCPUStat ¶ added in v0.0.6
GetProcessCPUStat gets current process's cpu stat
func GetProcessMemoryPercent ¶ added in v0.0.6
GetProcessMemoryStat gets current process's memory usage percent
func GetProcessMemoryStat ¶ added in v0.0.6
GetProcessMemoryStat gets current process's memory usage in Byte
func GetRoutineId ¶
func GetRoutineId() uint64
func GetThreadNum ¶ added in v0.0.6
func GetThreadNum() int
func GoRoutineInLoop ¶
func GoRoutineInLoop(function func())
func GoRoutineInTimer ¶
func GoSafely ¶ added in v0.0.6
func GoSafely(wg *sync.WaitGroup, ignoreRecover bool, handler func(), catchFunc func(r interface{}))
GoSafely wraps a `go func()` with recover()
func GoUnterminated ¶ added in v0.0.6
GoUnterminated is used for which goroutine wanna long live as its process. @period: sleep time duration after panic to defeat @handle panic so frequently. if it is not positive,
the @handle will be invoked asap after panic.
func InitFreeOS ¶ added in v0.0.7
func InitFreeOS()
func IsCgroup ¶ added in v0.0.6
func IsCgroup() bool
IsCgroup checks whether current os is a container or not
func IsLittleEndian ¶
func IsLittleEndian() bool
func OSIsUnix ¶ added in v0.0.7
OSIsUnix determines whether or not the given OS name is one of the unix-like operating systems recognized by Go.
func SwapEndianUin32 ¶
Types ¶
type OSMemStats ¶ added in v0.0.7
type OSMemStats struct { SwapTotal uint64 SwapUsed uint64 SwapFree uint64 SwapUsedPercent float64 SwapIn uint64 SwapOut uint64 MemTotal uint64 MemAvailable uint64 MemUsed uint64 MemUsedPercent float64 MemBuffers uint64 MemCached uint64 }
func GetOsMemStats ¶ added in v0.0.7
func GetOsMemStats() (OSMemStats, error)