parent
18e98b3320
commit
8d2ee23a5c
@ -0,0 +1,30 @@
|
||||
package golog
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
type System struct {
|
||||
Variable []string // 环境变量
|
||||
Hostname string // 主机名
|
||||
Twd string // 当前目录
|
||||
Uid int // 用户ID
|
||||
EUid int // 有效用户ID
|
||||
Gid int // 组ID
|
||||
EGid int // 有效组ID
|
||||
Pid int // 进程ID
|
||||
PPid int // 父进程ID
|
||||
}
|
||||
|
||||
func (s *System) Init() *System {
|
||||
s.Variable = os.Environ()
|
||||
s.Hostname, _ = os.Hostname()
|
||||
s.Twd, _ = os.Getwd()
|
||||
s.Uid = os.Getuid()
|
||||
s.EUid = os.Geteuid()
|
||||
s.Gid = os.Getgid()
|
||||
s.EGid = os.Getegid()
|
||||
s.Pid = os.Getpid()
|
||||
s.PPid = os.Getppid()
|
||||
return s
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package golog
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSystem(t *testing.T) {
|
||||
var s System
|
||||
s.Init()
|
||||
t.Logf("%+v", s)
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
package golog
|
||||
|
||||
const Version = "1.0.6"
|
||||
const Version = "1.0.7"
|
||||
|
Loading…
Reference in new issue