ps

package module
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: Apache-2.0 Imports: 5 Imported by: 22

README

gops

Go process tools

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindId added in v0.43.0

func FindId(name string) (int, error)

FindId finds the main process by matching the executable path. It looks for a process whose path contains "name" (case insensitive) and prioritizes main binaries (see FindMainIds), excluding helper processes. Returns the PID or -1 if not found.

func FindIds

func FindIds(name string) ([]int, error)

FindIds finds the all processes named with a subset of "name" (case insensitive), return matched IDs.

func FindMainIds added in v0.43.0

func FindMainIds(name string) ([]int, error)

FindMainIds finds all main process PIDs by matching the executable path. It looks for processes whose path contains "name" (case insensitive) and are main binaries, excluding helper processes:

  • macOS: the binary is under .app/Contents/MacOS/
  • Windows, Linux and others: the parent process runs a different executable (children of multi-process apps share the parent's binary)

Returns all matching main PIDs, or all matching PIDs if no main one is found.

func FindName

func FindName(pid int) (string, error)

FindName find the process name by the process id

func FindNames

func FindNames() ([]string, error)

FindNames find the all process name

func FindPath

func FindPath(pid int) (string, error)

FindPath find the process path by the process pid

func GetPid

func GetPid() int

GetPid get the process id

func IsRun added in v0.21.0

func IsRun(pid int) (bool, error)

IsRun return the process is runing or not

func Kill

func Kill(pid int) error

Kill kill the process by PID

func PidExists

func PidExists(pid int) (bool, error)

PidExists determine whether the process exists

func Pids

func Pids() ([]int, error)

Pids get the all process id

func Run added in v0.21.0

func Run(path string) ([]byte, error)

Run command shell

func Status added in v0.21.0

func Status(pid int) ([]string, error)

Status return the process status

func ToInt added in v0.30.0

func ToInt(pid []int32) (res []int)

ToInt convert []int32 to []int

Types

type Nps

type Nps struct {
	// Pid  int32
	Pid  int
	Name string
}

Nps process struct

func Process

func Process() ([]Nps, error)

Process get the all process struct

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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