Documentation
¶
Overview ¶
Package binary implements simple translation between numbers and byte sequences and encoding and decoding of varints.
Numbers are translated by reading and writing fixed-size values. A fixed-size value is either a fixed-size arithmetic type (int8, uint8, int16, float32, complex64, ...) or an array or struct containing only fixed-size values.
The varint functions encode and decode single integer values using a variable-length encoding; smaller values require fewer bytes. For a specification, see http://code.google.com/apis/protocolbuffers/docs/encoding.html.
This package favors simplicity over efficiency. Clients that require high-performance serialization, especially for large data structures, should look at more advanced solutions such as the encoding/gob package or protocol buffers.
Index ¶
- Constants
- Variables
- func PidExists(pid int32) (bool, error)
- func Pids() ([]int32, error)
- func Read(r io.Reader, order ByteOrder, data interface{}) error
- func Size(v interface{}) int
- func Write(w io.Writer, order ByteOrder, data interface{}) error
- type AuMask
- type AuTidAddr
- type Au_session
- type AuditinfoAddr
- type ByteOrder
- type Eproc
- type ExternProc
- type IOCountersStat
- type Itimerval
- type KinfoProc
- type Label
- type MemoryInfoExStat
- type MemoryInfoStat
- type MemoryMapsStat
- type NumCtxSwitchesStat
- type OpenFilesStat
- type Pgrp
- type Posix_cred
- type Proc
- type Process
- func (p *Process) CPUAffinity() ([]int32, error)
- func (p *Process) CPUPercent(interval time.Duration) (float64, error)
- func (p *Process) CPUTimes() (*cpu.CPUTimesStat, error)
- func (p *Process) Children() ([]*Process, error)
- func (p *Process) Cmdline() (string, error)
- func (p *Process) Connections() ([]net.NetConnectionStat, error)
- func (p *Process) CreateTime() (int64, error)
- func (p *Process) Cwd() (string, error)
- func (p *Process) Exe() (string, error)
- func (p *Process) Gids() ([]int32, error)
- func (p *Process) IOCounters() (*IOCountersStat, error)
- func (p *Process) IOnice() (int32, error)
- func (p *Process) IsRunning() (bool, error)
- func (p *Process) Kill() error
- func (p *Process) MemoryInfo() (*MemoryInfoStat, error)
- func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error)
- func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error)
- func (p *Process) MemoryPercent() (float32, error)
- func (p *Process) Name() (string, error)
- func (p *Process) Nice() (int32, error)
- func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error)
- func (p *Process) NumFDs() (int32, error)
- func (p *Process) NumThreads() (int32, error)
- func (p *Process) OpenFiles() ([]OpenFilesStat, error)
- func (p *Process) Parent() (*Process, error)
- func (p *Process) Ppid() (int32, error)
- func (p *Process) Resume() error
- func (p *Process) Rlimit() ([]RlimitStat, error)
- func (p *Process) SendSignal(sig syscall.Signal) error
- func (p *Process) Status() (string, error)
- func (p Process) String() string
- func (p *Process) Suspend() error
- func (p *Process) Terminal() (string, error)
- func (p *Process) Terminate() error
- func (p *Process) Threads() (map[string]string, error)
- func (p *Process) Uids() ([]int32, error)
- func (p *Process) Username() (string, error)
- type Rlimit
- type RlimitStat
- type Rusage
- type Session
- type Sigacts
- type Timespec
- type Timeval
- type UGid_t
- type UcredQueue
- type Upcred
- type UserStruct
- type Uucred
- type Vmspace
- type Vnode
Constants ¶
const ( CTLKern = 1 // "high kernel": proc, limits KernProc = 14 // struct: process entries KernProcPID = 1 // by process id KernProcProc = 8 // only return procs KernProcAll = 0 // everything KernProcPathname = 12 // path to executable )
copied from sys/sysctl.h
Variables ¶
var BigEndian bigEndian
BigEndian is the big-endian implementation of ByteOrder.
var LittleEndian littleEndian
LittleEndian is the little-endian implementation of ByteOrder.
Functions ¶
func Read ¶
Read reads structured binary data from r into data. Data must be a pointer to a fixed-size value or a slice of fixed-size values. Bytes read from r are decoded using the specified byte order and written to successive fields of the data. When reading into structs, the field data for fields with blank (_) field names is skipped; i.e., blank field names may be used for padding. When reading into a struct, all non-blank fields must be exported.
func Size ¶
func Size(v interface{}) int
Size returns how many bytes Write would generate to encode the value v, which must be a fixed-size value or a slice of fixed-size values, or a pointer to such data. If v is neither of these, Size returns -1.
func Write ¶
Write writes the binary representation of data into w. Data must be a fixed-size value or a slice of fixed-size values, or a pointer to such data. Bytes written to w are encoded using the specified byte order and read from successive fields of the data. When writing structs, zero values are written for fields with blank (_) field names.
Types ¶
type Au_session ¶
type Au_session struct {
Aia_p *AuditinfoAddr
Mask AuMask
}
type AuditinfoAddr ¶
type ByteOrder ¶
type ByteOrder interface {
Uint16([]byte) uint16
Uint32([]byte) uint32
Uint64([]byte) uint64
PutUint16([]byte, uint16)
PutUint32([]byte, uint32)
PutUint64([]byte, uint64)
String() string
}
A ByteOrder specifies how to convert byte sequences into 16-, 32-, or 64-bit unsigned integers.
type Eproc ¶
type Eproc struct {
Paddr *uint64
Sess *Session
Pcred Upcred
Ucred Uucred
Pad_cgo_0 [4]byte
Vm Vmspace
Ppid int32
Pgid int32
Jobc int16
Pad_cgo_1 [2]byte
Tdev int32
Tpgid int32
Pad_cgo_2 [4]byte
Tsess *Session
Wmesg [8]int8
Xsize int32
Xrssize int16
Xccount int16
Xswrss int16
Pad_cgo_3 [2]byte
Flag int32
Login [12]int8
Spare [4]int32
Pad_cgo_4 [4]byte
}
type ExternProc ¶
type ExternProc struct {
P_un [16]byte
P_vmspace uint64
P_sigacts uint64
Pad_cgo_0 [3]byte
P_flag int32
P_stat int8
P_pid int32
P_oppid int32
P_dupfd int32
Pad_cgo_1 [4]byte
User_stack uint64
Exit_thread uint64
P_debugger int32
Sigwait int32
P_estcpu uint32
P_cpticks int32
P_pctcpu uint32
Pad_cgo_2 [4]byte
P_wchan uint64
P_wmesg uint64
P_swtime uint32
P_slptime uint32
P_realtimer Itimerval
P_rtime Timeval
P_uticks uint64
P_sticks uint64
P_iticks uint64
P_traceflag int32
Pad_cgo_3 [4]byte
P_tracep uint64
P_siglist int32
Pad_cgo_4 [4]byte
P_textvp uint64
P_holdcnt int32
P_sigmask uint32
P_sigignore uint32
P_sigcatch uint32
P_priority uint8
P_usrpri uint8
P_nice int8
P_comm [17]int8
Pad_cgo_5 [4]byte
P_pgrp uint64
P_addr uint64
P_xstat uint16
P_acflag uint16
Pad_cgo_6 [4]byte
P_ru uint64
}
type IOCountersStat ¶
type IOCountersStat struct {
ReadCount uint64 `json:"read_count"`
WriteCount uint64 `json:"write_count"`
ReadBytes uint64 `json:"read_bytes"`
WriteBytes uint64 `json:"write_bytes"`
}
func (IOCountersStat) String ¶
func (i IOCountersStat) String() string
type KinfoProc ¶
type KinfoProc struct {
Proc ExternProc
Eproc Eproc
}
type MemoryInfoStat ¶
type MemoryInfoStat struct {
RSS uint64 `json:"rss"` // bytes
VMS uint64 `json:"vms"` // bytes
Swap uint64 `json:"swap"` // bytes
}
func (MemoryInfoStat) String ¶
func (m MemoryInfoStat) String() string
type MemoryMapsStat ¶
type MemoryMapsStat struct {
}
type NumCtxSwitchesStat ¶
type NumCtxSwitchesStat struct {
Voluntary int64 `json:"voluntary"`
Involuntary int64 `json:"involuntary"`
}
func (NumCtxSwitchesStat) String ¶
func (p NumCtxSwitchesStat) String() string
type OpenFilesStat ¶
func (OpenFilesStat) String ¶
func (o OpenFilesStat) String() string
type Posix_cred ¶
type Process ¶
type Process struct {
Pid int32 `json:"pid"`
// contains filtered or unexported fields
}
func NewProcess ¶
func (*Process) CPUAffinity ¶
func (*Process) CPUPercent ¶
If interval is 0, return difference from last call(non-blocking). If interval > 0, wait interval sec and return diffrence between start and end.
func (*Process) Connections ¶
func (p *Process) Connections() ([]net.NetConnectionStat, error)
func (*Process) CreateTime ¶
func (*Process) IOCounters ¶
func (p *Process) IOCounters() (*IOCountersStat, error)
func (*Process) MemoryInfo ¶
func (p *Process) MemoryInfo() (*MemoryInfoStat, error)
func (*Process) MemoryInfoEx ¶
func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error)
func (*Process) MemoryMaps ¶
func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error)
func (*Process) MemoryPercent ¶
func (*Process) NumCtxSwitches ¶
func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error)
func (*Process) NumThreads ¶
func (*Process) OpenFiles ¶
func (p *Process) OpenFiles() ([]OpenFilesStat, error)
func (*Process) Rlimit ¶
func (p *Process) Rlimit() ([]RlimitStat, error)
type RlimitStat ¶
type RlimitStat struct {
Resource int32 `json:"resource"`
Soft int32 `json:"soft"`
Hard int32 `json:"hard"`
}
func (RlimitStat) String ¶
func (r RlimitStat) String() string
type UcredQueue ¶
type UcredQueue struct {
Next *ucred
Prev **ucred
}
type UserStruct ¶
type UserStruct struct{}